I am making a view in SceneBuilder for my JavaFX application. I want my view to be maximized. How can I achieve this in SceneBuilder or the .fxml
file?
5 Answers
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.

- 5,031
- 5
- 37
- 64

- 36,135
- 10
- 122
- 176
-
pity :( , I am programming an application, it must be full window. I work layouts with scene builder. It can be different space out components if its normal or full size. – Navi89CZ Jul 15 '15 at 11:41
-
2You can do it, you just can't do it directly in SceneBuilder, which is a tool for designing the layout, not managing the window(s). – James_D Jul 15 '15 at 12:02
-
1@Adempiere_HotCake On which version of JavaFX are you trying to run it? `setMaximzed()` was included in JavaFX 8. – ItachiUchiha Sep 29 '15 at 08:54
-
1running this with, JDK 7 , Scene builder 2.0 and Java FX Included in IntelliJ. – JavaDragon Sep 29 '15 at 11:52
-
This method doesn't exist in JDK 7, as said above, this was included in JavaFX 8 which is a part of JDK8. – ItachiUchiha Sep 29 '15 at 12:45
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());

- 155
- 1
- 8
-
I tried this. It add some extra height to the stage. I am suspecting the title bar's height. – burntblark Feb 12 '17 at 07:19
-
This is the code that works for me
primaryStage.setMaximized(true);
it miximizes my window screen on the launch of the app.

- 31
- 2
I agree with Yemmy1000. primaryStage.setMaximized(true) works fine for me.
primaryStage.setScene(new Scene(root, 1800, 850));
primaryStage.setMaximized(true);
This code will go to width: 1800 and height:900 when restored down from maximum.

- 21
- 3
Two properties I found in stage which are useful. First is setFullScreen(boolean) which will set your view to full screeb, but it will also hide all the taskbar and header of view.
Second is setMaximized(boolean) which will set you view to perfect like any other application view size.
I an using setMaximized(true) for my application.

- 13
- 4