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

SplitPane does not remember divider positions.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • 8u20
    • 8
    • javafx
    • Java8-ea-b103 on MSWindows Seven Home Premium (fairly up-to-date).
      IDE (should not matter): Eclipse with e(fx)clipse extensions.

      IMHO divider code has a logical flaw because it has a single value (set directly via SplitPane.setDividerPositions()), instead of the usual three: min/max/pref (managed by layout.
      The following short program (I'm using the same code to demonstrate three related bugs) shows the problem.

      After startup you get a maximized window with adjusted dividers.
      Going maximized -> restore -> maximized You can see divider positions change, where user would expect them to remain the same.

      Other kind of resizing show similar problems I assume spawn from a bad interaction between dividerPositions and various (min|max|pref)(Width|Height).

      Note: I did not find a way to attach a file to Issue, so I put the code inline here.
      =========================================================
      import java.util.Timer;
      import java.util.TimerTask;

      import javafx.application.Application;
      import javafx.application.Platform;
      import javafx.geometry.Orientation;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.control.SplitPane;
      import javafx.scene.layout.HBox;
      import javafx.stage.Stage;

      public class Main2 extends Application {
      public static void main(String[] args) {
      launch(args);
      }

      @Override
      public void start(Stage primaryStage) throws Exception {
      final SplitPane root = new SplitPane();
      root.setOrientation(Orientation.VERTICAL);
      final SplitPane child;
      {
      {
      child = new SplitPane();
      child.setDividerPositions(0.3);
      {
      HBox h = new HBox();
      h.getChildren().add(new Label("LEFT"));
      child.getItems().add(h);
      }
      {
      HBox h = new HBox();
      h.getChildren().add(new Label("RIGHT"));
      child.getItems().add(h);
      }
      root.getItems().add(child);
      }
      {
      HBox bottom = new HBox();
      bottom.getChildren().add(new Label("Bottom"));
      root.getItems().add(bottom);
      }
      }
      root.setDividerPositions(0.8);
      Scene s = new Scene(root);
      primaryStage.setScene(s);
      primaryStage.setMaximized(true);

      Timer timer = new Timer(true);
      timer.schedule(new TimerTask() {
      @Override
      public void run() {
      Platform.runLater(new Runnable() {
      @Override
      public void run() {
      child.setDividerPositions(0.3);
      child.layout(); // fixed by forcing a relayout!!!
      root.setDividerPositions(0.8);
      }
      });
      }
      }, 1000);
      primaryStage.show();
      }
      }
      =========================================================

            miflemi Mick Fleming
            mcondareljfx Mauro Condarelli (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: