User interface JavaFX将舞台最小尺寸设置为场景首选尺寸

User interface JavaFX将舞台最小尺寸设置为场景首选尺寸,user-interface,layout,javafx,fxml,User Interface,Layout,Javafx,Fxml,我想实现像应用程序必须是900x600的最小大小,而使用可以拖动调整到更大的大小。这是我的主要场景: <BorderPane xmlns:fx="http://javafx.com/fxml/1" minHeight="600.0" minWidth="900.0" prefHeight="600.0" prefWidth="900.0" styleClass="root" fx:controller="taidict

我想实现像应用程序必须是900x600的最小大小,而使用可以拖动调整到更大的大小。这是我的主要场景:

<BorderPane xmlns:fx="http://javafx.com/fxml/1"
            minHeight="600.0" minWidth="900.0"
            prefHeight="600.0" prefWidth="900.0"
            styleClass="root" fx:controller="taidictionary.MainForm">
<!-- many controls -->
</BorderPane>

异常情况是,我仍然可以将窗口(stage)调整为小于900x600的大小。这是因为布局控件的填充。

“异常情况是,我仍然可以将窗口(后台)的大小调整为小于900x600的大小。这是因为布局控件的填充。”。对不起,你能详细解释一下这个问题吗?从逻辑上讲,我只能将应用程序的大小调整到大于900 x 600的大小。但是,我可以调整应用程序的大小,使其略小于900 x 600。如果我应用
stage.setMinWidth(920);stage.setMinHeight(620)
,然后就可以了。啊,好的。问题在于舞台的装饰,因为当您设置最小尺寸时,它也会被计算在内。这可以帮助您:
Parent root = FXMLLoader.load(getClass().getResource("MainForm.fxml"));
Scene scene = new Scene(root);
stage.setTitle("Tai Dictionary");        
stage.getIcons().add(new Image(getClass().getResourceAsStream("/images/TaiDictionaryIcon.png")));
stage.setScene(scene);
stage.setMinWidth(900.0);
stage.setMinHeight(600.0);
stage.show();