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?
Press down the control key and use the mouse scroll wheel to zoom to any part of the screen.
Select button in scene builder, on right side go to properties -> JavaFx CSS section. You can use custom css class.
You have to set the stage initStyle to undecorated,then create the Basic Layout of your app. Lets assume using a BorderPane and in the top create the element you have in the image. The default header of the Stage is OS dependent,so you have to create your own.
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());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With