简体   繁体   English

如何使 Javafx 应用程序使用在 Scene Builder 中传递给它的屏幕分辨率?

[英]How to make a Javafx app use the screen resolution that's passed into it in Scene Builder?

I have the following JavaFx application and use Scene builder.我有以下 JavaFx 应用程序并使用场景生成器。 I want my scene to have the screen resolution 1920*1080 :我希望我的场景具有屏幕分辨率1920*1080 设置屏幕分辨率的参数

My display has following resolution:我的显示器具有以下分辨率:

显示屏幕分辨率为 2880 x 1800 像素的图像

But after running code I have the application that can't even fit into my window.但是在运行代码之后,我的应用程序甚至无法放入我的 window。 Is this caused by incorrect scaling, or something else?这是由于缩放不正确还是其他原因引起的?

桌面显示应用程序不适合窗口

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.您的标题要求默认完成的操作,因为尺寸信息已在用于创建视图的 xml 中注册。

Try Adding the below piece of code in your main class.尝试在您的主 class 中添加以下代码。 This will maximize the window to fit your screen resolution这将最大化 window 以适应您的屏幕分辨率

Note: However the size of the icons which are shown on your app screen may not change.注意:但是,您的应用程序屏幕上显示的图标大小可能不会改变。

stage.setMaximized(true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM