Reputation: 167
I am planning on making a full screen application in 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
Upvotes: 0
Views: 309
Reputation: 44414
Approach 2.
is preferred. 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.
Upvotes: 1