0

I'm using JavaFx version 8.0.131
I want to set JavaFx stage maximized but not resizable but following code does not working.

Here is my code:

public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setMaximized(true);
    stage.setResizable(false);
    stage.show();
}  

It just does set Resizable false but not Maximized true.

Swapnil
  • 115
  • 1
  • 12

1 Answers1

1

Instead of stage.setMaximized(true); and setResizable(false);
I tried following code that solved the problem.

Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());

    stage.show();
Swapnil
  • 115
  • 1
  • 12