如何将JavaFX舞台/框架设置为最大化 [英] How to set a JavaFX Stage/Frame to Maximized

查看:99
本文介绍了如何将JavaFX舞台/框架设置为最大化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JavaFX2.我希望将框架最大化地打开,但没有找到解决方法.我在互联网上搜索了一下但没有成功.在此阶段,我看到了setFullScreen()setIconified(),但是没有看到类似setMaximized()的东西.

I'm using JavaFX 2. I want my frame to open maximized but I'm not seeing a way. I searched a bit on the internet without success. For the stage I see setFullScreen() and setIconified() but I don't see anything like setMaximized().

推荐答案

评估JavaFX 2.0 SDK样本随附的Ensemble.jar的源代码时,当前实现窗口最大化的有效方法是

When evaluating the sourcecode of the Ensemble.jar provided with the samples of JavaFX 2.0 SDK, the currently valid way to achieve window maximizing is

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

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

(您可以在WindowButtons.java中找到类似的代码)

(you find similar code in WindowButtons.java)

最大化"按钮仍处于启用状态,当单击它时,窗口将增加一些(Windows操作系统).此后,最大化"按钮被禁用.在提供的示例中,替换了标准按钮.也许这仍然是一个问题.

The 'maximize' button is still enabled and when clicking it, the windows will grow a bit more (Windows OS). After this the 'maximize 'button is disabled. In the provided example the standard buttons are replaced. Maybe this is still an issue.

这篇关于如何将JavaFX舞台/框架设置为最大化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆