Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JavaFX SplitPane Divider Position Inconsistent Behaviour

947038Feb 25 2013 — edited Feb 26 2013
I have two StackPanes (pane1 & pane2) being displayed in a SplitPane (splitPane). The SplitPane's divider position is set to .3 in the builder. The seond StackPane (pane2) contains a Button which also sets the SplitPane's divider position to .3.

Ceteris paribus, the expected behaviour would be that both actions (setting the divider position in the builder & setting the divider position through an action) either work or not.

Yet, only the latter actually works.

What changes between the construction of the SplitPane and the onAction of the Button? What hinders the placement of the divider in the builder?
    StackPane pane1 = new StackPane();
    StackPane pane2 = new StackPane();

    final SplitPane splitPane = SplitPaneBuilder.create()
            .items(pane1, pane2)
            .dividerPositions(new double[] {.3})
            .orientation(Orientation.HORIZONTAL)
            .build();

    pane2.getChildren().add(ButtonBuilder.create()
            .text("Divider Position")
            .onAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent event) {
                    splitPane.setDividerPositions(.3);
                }
            })
            .build());

    Scene primaryScene = SceneBuilder.create()
            .root(splitPane)
            .build();

    primaryStage.setScene(primaryScene);
    primaryStage.setTitle("Name");
    primaryStage.setWidth(500);
    primaryStage.setHeight(500);
    primaryStage.show();

    splitPane.setDividerPositions(.3);
(see also http://stackoverflow.com/questions/15041332/javafx-divider-position-inconsistent-behaviour)
This post has been answered by James_D on Feb 25 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 26 2013
Added on Feb 25 2013
2 comments
2,469 views