简体   繁体   English

setExtendedState(JFrame.MAXIMIZED_BOTH)或GraphicsDevice设备哪个更好?

[英]which is better setExtendedState(JFrame.MAXIMIZED_BOTH) or GraphicsDevice device?

I am planning on making a full screen application in Java. 我打算用Java制作全屏应用程序。 I have come across 2 sets of ways to make the application full screen. 我遇到了两种使应用程序全屏显示的方法。

1. frame.setExtendedState(JFrame.MAXIMIZED_BOTH)
2. GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0];
    device.setFullScreenWindow(frame);

Both of these do the same that is make the frame full screen. 两者的作用都是使全屏显示。 What I would like to know which of these are better? 我想知道其中哪个更好? If I was to use this application on different screen resolution would they behave the same .Example projectors etc 如果我要在不同的屏幕分辨率下使用此应用程序,它们的行为是否相同。示例投影仪等

Approach 2. is preferred. 首选方法2. The best thing to do is check if fullscreen mode is available: 最好的办法是检查是否可以使用全屏模式:

if (device.isFullScreenSupported()) {
    device.setFullScreenWindow(frame);
} else {
    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
}

Maximizing a frame is the equivalent of double-clicking the title bar. 最大化框架等同于双击标题栏。 It will not fill the parts of the screen used by the desktop's taskbar or other reserved areas, and its decorations (title bar, border, close/minimize/maximize buttons) will still be visible, which probably is not what you want. 它不会填充桌面任务栏或其他保留区域使用的屏幕部分,并且其装饰(标题栏,边框,关闭/最小化/最大化按钮)仍然可见,这可能不是您想要的。

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

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