Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8367322

SplitPane ignores divider positions when ResizableWithParent = false

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      When a new item with (ResizableWithParent = false) is added and divider positions are set, SplitPane ignores specified positions.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the provided code and press the button.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The added pane must be visible and the output of the program should be:
      Current pulse: [0.5]
      2nd pulse: [0.5]
      3rd pulse: [0.5]

      ACTUAL -
      The added pane is not visible and the output of the program is:
      Current pulse: [0.5]
      2nd pulse: [0.5]
      3rd pulse: [0.9797297297297297]


      ---------- BEGIN SOURCE ----------
      public class TestFx extends Application {

          public static void main(String[] args) {
              launch(args);
          }

          private final SplitPane splitPane = new SplitPane();

          @Override
          public void start(Stage primaryStage) {
              splitPane.getItems().add(createItem(0));
              splitPane.setOrientation(Orientation.VERTICAL);
              VBox.setVgrow(splitPane, Priority.ALWAYS);
              var fooPane = new Pane(new Label("Foo pane"));
              VBox.setVgrow(fooPane, Priority.ALWAYS);

              var button = new Button("Test");
              button.setOnAction(e -> {
                  splitPane.getItems().add(createItem(1));
                  splitPane.setDividerPositions(new double[]{0.5});
                  printDividerPositions("Current pulse: ");
                  Platform.runLater(() -> printDividerPositions("2nd pulse: "));
                  Platform.runLater(() -> Platform.runLater(() -> printDividerPositions("3rd pulse: ")));
              });

              var root = new VBox(splitPane, fooPane, button);
              Scene scene = new Scene(root, 500, 300);
              primaryStage.setScene(scene);
              primaryStage.show();
          }

          private void printDividerPositions(String pulseInfo) {
              System.out.println(pulseInfo + Arrays.toString(splitPane.getDividerPositions()));
          }

          private Pane createItem(int index) {
              var pane = new Pane(new Label("Item : " + index));
              if (index == 0) {
                  SplitPane.setResizableWithParent(pane, true);
              } else {
                  SplitPane.setResizableWithParent(pane, false);
              }
              return pane;
          }
      }
      ---------- END SOURCE ----------

        1. TestFx.java
          2 kB
          Praveen Narayanaswamy
        2. Screenshot 2025-09-10 150337.png
          10 kB
          Praveen Narayanaswamy
        3. SplitPane_Dividers_8367322.java
          3 kB
          Andy Goryachev
        4. recorging_Ubuntu.mp4
          31.12 MB
          Anupam Dev

            angorya Andy Goryachev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: