本文介绍了JavaFX窗口大小调整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在同一操作系统上看起来不同这是 Windows 7 丰富的界面:

My app looks different at same OS. This is Windows 7 rich interface:

Windows 7 常规界面:

唯一令我生气的是尺码。在FXML中,它是 640x445 ,但Windows 7使它更宽。我怎么能避免这种情况?是否有办法让 TextArea 全屏或什么?

The only thing that makes me angry is sizing. In FXML it's 640x445, but Windows 7 makes it wider. How can I avoid that? Is there an approach to make TextArea fullscreen or something?

推荐答案

在初始化时调整你的舞台大小你可以使用下面的代码(我假设你使用javafx-2?)

To resize your stage at initialize you can use following code (i assume you use javafx-2?)

//stage.setResizable(true);

Screen screen = Screen.getPrimary();    
Rectangle2D bounds = screen.getVisualBounds();

stage.setX(bounds.getMinX());
stage.setY(bounds.getMinY());
stage.setWidth(bounds.getWidth());
stage.setHeight(bounds.getHeight());

或者您可以使用全屏模式:

or you can use fullscreen mode:

stage.setFullScreen(true);

这篇关于JavaFX窗口大小调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 05:16