79390

Question:
I'm currently building a small UI application for personal purpose and I ran into a problem. Here is some code:
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("ui.fxml"));
Scene scene = new Scene(root);
stage.setTitle("My app");
stage.setScene(scene);
stage.setMinHeight(608.0);
stage.setMinWidth(1080.0);
stage.show();
}
And here's the FXML code assiociated with:
<GridPane gridLinesVisible="true" minHeight="608.0" minWidth="1080.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="my.package.MyClass">
<rowConstraints>
<RowConstraints minHeight="500.0" prefHeight="500.0" vgrow="ALWAYS" />
<RowConstraints maxHeight="108.0" minHeight="108.0" prefHeight="108.0" vgrow="NEVER" />
</rowConstraints>
</GridPane>
So, my problem is that, at launch, the GridPane will effectively have a height of 608px
but is still resizable to a smaller height. Indeed, it will be resizable until the <strong>stage</strong> will be 608px
, including the title bar's height...
The behaviour I would like to have is that my GridPane can't have a smaller height than 608.0
.
Do you know any ways to do that? Many thanks in advance!
Answer1:As @James_D pointed out in a comment, I simply had to modify my code as follow:
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("ui.fxml"));
Scene scene = new Scene(root);
stage.setTitle("My app");
stage.setScene(scene);
stage.show();
stage.setMinHeight(stage.getHeight());
stage.setMinWidth(stage.getWidth());
}