6

ウィンドウの最小サイズを設定するにはどうすればよいですか? 値を設定しようとしましたminHeight minWidthが、マウスを使用してこの値の下でウィンドウのサイズを変更できます。

これが私のFXMLルートペインです:

<BorderPane fx:id="borderPane"
        minHeight="200" minWidth="400" prefHeight="600" prefWidth="800"
        xmlns="http://javafx.com/javafx/null"
        xmlns:fx="http://javafx.com/fxml/1"
        fx:controller="simulation.Simulation_Controller">
</BorderPane>
4

2 に答える 2

2

シンプルで実用的なソリューションを次に示します。

Parent root = FXMLLoader.load(getClass().getResource("/your/layout.fxml"));

stage.setMinWidth(root.minWidth(-1));
stage.setMinHeight(root.minHeight(-1));

これにより、ステージの最小サイズが FXML ファイルの最上位要素で定義された値に設定されるか、定義されていない場合は 0 に設定されます。

于 2017-11-06T09:53:19.907 に答える