5

I can't figure out how to listen for a "Divider Repositioned" event on a JavaFX 8 SplitPane. Here is a simple working Application that just needs the event listener added. Can someone help point me in the right direction?

public class TestCase extends Application {
    public void start(Stage primaryStage) throws Exception {
        Pane leftPane = new Pane();
        Pane rightPane = new Pane();
        SplitPane splitPane = new SplitPane(leftPane, rightPane);

        // Need to create a listener that fires whenever the SplitPane's Divider is repositioned
        // Within this listener I need access to the leftPane and rightPane so I can call requestLayout()

        primaryStage.setScene(new Scene(splitPane));
        primaryStage.setWidth(800);
        primaryStage.setHeight(600);
        primaryStage.show();
    }


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

1 回答 1

5

您可以获取分隔线splitPane.getDividers()并将 ChangeListeners 添加到dividers.positionProperty().

于 2016-02-17T18:03:12.907 回答