边框的中心(子场景)未调整大小

时间:2020-07-15 00:38:51

标签: java javafx

我正在制作一个在BorderPane中心使用SubScene实例的应用程序,在右侧我想放置一个包含一些内容的vbox。子场景以正确的大小开始,并在最大化窗口时完美调整其大小。 before maximizingmaximized

问题是,在最小化窗口时会发生这种情况: minimized

我该怎么办?

这是我调整大小系统的方法:

SubScene subScene = new SubScene(group, 1200, 700, true, SceneAntialiasing.BALANCED);  
HBox centerBox = new HBox();

subScene.widthProperty().bind(centerBox.widthProperty());
subScene.heightProperty().bind(centerBox.heightProperty());

centerBox.getChildren().add(subScene);

1 个答案:

答案 0 :(得分:0)

针对任何有相同问题的人。我solved it通过将SubScene的width和height属性与场景绑定在一起,然后减去相邻节点的width(200)和height(75):

    //  Scene scene = new Scene(root, 1200, 800, true);
    //  SubScene subScene = new SubScene(group, 1200, 700, true, SceneAntialiasing.BALANCED);
    //  centerBox is an instance of HBox

    subScene.widthProperty().bind(scene.widthProperty().subtract(200));
    subScene.heightProperty().bind(scene.heightProperty().subtract(75));
    centerBox.getChildren().add(subScene);