且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在JavaFX中监听大小调整事件

更新时间:2023-02-05 22:32:44

heightPropertywidthProperty.您可以使用这些属性进行绑定,也可以向其添加侦听器.

There are heightProperty and widthProperty. You can use these properties for binding, or add listeners to them.

public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 300, 200);
    stage.setScene(scene);

    stage.titleProperty().bind(
            scene.widthProperty().asString().
            concat(" : ").
            concat(scene.heightProperty().asString()));

    stage.show();
}

或查看下一个示例: https://***.com/a/9893911/1054140