How to make window fullscreen/maximized in Scene Builder?

You cannot do that using Scene Builder, since maximize or fullScreen are properties of the Stage and not the layouts set on the scene.

You can load and set the .fxml on the scene and later set the scene on the stage.

The following methods can be used on the stage :

  • setMaximized(boolean) - To maximize the stage and fill the screen.
  • setFullScreen(boolean) - To set stage as full-screen, undecorated window.

As you cannot maximize your view in fxml, you have to set the size of the stage to be maximized. There is no direct method for setting the size of the stage to be maximized in javafx 2 but there is another way you can do this. It is by manually setting the size of the stage. You can use this code:

Screen screen = Screen.getPrimary();
Rectangle2D bounds = screen.getVisualBounds();

primaryStage.setX(bounds.getMinX());
primaryStage.setY(bounds.getMinY());
primaryStage.setWidth(bounds.getWidth());
primaryStage.setHeight(bounds.getHeight());

This is the code that works for me

primaryStage.setMaximized(true);

it miximizes my window screen on the launch of the app.