Home > Software engineering >  How to make a Javafx app use the screen resolution that's passed into it in Scene Builder?
How to make a Javafx app use the screen resolution that's passed into it in Scene Builder?

Time:11-26

I have the following JavaFx application and use Scene builder. I want my scene to have the screen resolution 1920*1080: Parameters for set screen resolution

My display has following resolution:

Image showing screen resolution as 2880 by 1800 pixels

But after running code I have the application that can't even fit into my window. Is this caused by incorrect scaling, or something else?

Desktop showing application not fitting in window

CodePudding user response:

this ?

double height=  Screen.getPrimary().getBounds().getHeight();   
double width=   Screen.getPrimary().getBounds().getWidth();  
scene = new Scene(root,width , height);  
          

tho your title is asking for something that's done by default as size infos are registered in the xml used to create your views.

CodePudding user response:

Try Adding the below piece of code in your main class. This will maximize the window to fit your screen resolution

Note: However the size of the icons which are shown on your app screen may not change.

stage.setMaximized(true);
  • Related