javajavafxfxmlwindow-resizeminimum-size

FXML minHeight & minWidth attributs ignored?


How can I set a minimum size to my window ? I try to set the minHeight minWidth value but I can still resize the Window under this values with the mouse.

Here is my FXML root pane:

<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>

Solution

  • To do so you have to set the minHeight and minWidth of your Stage.

    Somewhere in your java code...:

    Example:

    ...
    yourStage.setMinHeight(480);
    yourStage.setMinWidth(640);
    ...