gpt4 book ai didi

listener - 如何将监听器添加到 SplitPane Divider 位置?

转载 作者:行者123 更新时间:2023-12-01 13:50:56 25 4
gpt4 key购买 nike

我不知道如何在 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() .

关于listener - 如何将监听器添加到 SplitPane Divider 位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31683912/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com