Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make window fullscreen/maximized in Scene Builder?

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?

like image 994
Navi89CZ Avatar asked Jul 15 '15 09:07

Navi89CZ


People also ask

How do you zoom in Scene Builder?

Press down the control key and use the mouse scroll wheel to zoom to any part of the screen.

How do I change the color of my buttons in Scenebuilder?

Select button in scene builder, on right side go to properties -> JavaFx CSS section. You can use custom css class.

How do I change the stage color in Javafx?

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.


2 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.
like image 185
ItachiUchiha Avatar answered Jan 02 '23 00:01

ItachiUchiha


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()); 
like image 20
Taher Tayabali Avatar answered Jan 02 '23 01:01

Taher Tayabali