Fullscreen frame in Swing
With the command GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
I can get the screen size, but I don't know how to set this size in my frame.
I want to configure my frame to always be adjusted in the screen, rega开发者_高级运维rdless of screen size.
I'm not sure exactly what you want - fullscreen mode or just to maximize the JFrame
.
Fullscreen exclusive mode is used for things like games or kiosk displays - your app is the only thing visible and able to be interacted with. Here's a link to some fullscreen exclusive mode documentation and tutorials.
On the other hand, if you just want to maximize the JFrame
this means that you still want the regular old "window inside the desktop" experience, just that the window is maximized to take up all the available desktop space. In this case, you would just call the setExtendedState(JFrame.MAXIMIZED_BOTH) on your JFrame
right after you set it visible.
精彩评论