Disable maximize button and resizing window in JavaFX
32,073
Solution 1
This is the best way
primaryStage.setResizable(false);
example:
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("views/homePage.fxml"));
primaryStage.setTitle("Resizing");
primaryStage.setScene(new Scene(root, 750, 601));
primaryStage.setResizable(false);
primaryStage.show();
}
Solution 2
primaryStage.maximizedProperty().addListener((observable, oldValue, newValue) -> {
if (newValue)
primaryStage.setMaximized(false);
});
It listens for the maximize event then checks whether it's actually maximizing through if (newVale)
then forces the stage to disable maximization.
Solution 3
stage.setMaxHeight(double TheHeightYouGot);
stage.setMaxWidth(double TheWidthYouGot);
stage.setResizable(false);
Author by
user1406186
Updated on August 01, 2022Comments
-
user1406186 almost 2 years
I have modality window. I want the window to be able to be minimized and closed, but not resized or maximized.
How do I disable the maximize button and prevent resizing of the window?