如何将监听器添加到 SplitPane 分隔线位置?

How to add listeners to SplitPane Divider positions?

我不知道如何在 JavaFX 8 SplitPane 上监听 "Divider Repositioned" 事件。这是一个简单的工作应用程序,只需要添加事件侦听器。有人可以帮我指出正确的方向吗?

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);
    }
}

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