Is there a way to do that without having the user type in their resolution manually? Thanks for any help in advance.
-
I use `setExtendedState( this.getExtendedState()|JFrame.MAXIMIZED_BOTH );` – Clark Kent Aug 01 '13 at 14:03
3 Answers
Use frame.setExtendedState(Frame.MAXIMIZED_BOTH); to make your Swing gui to full screen. refer Oracle doc for more information

- 45
- 5
Use
setExtendedState(JFrame.MAXIMIZED_BOTH);
http://docs.oracle.com/javase/6/docs/api/java/awt/Frame.html#setExtendedState%28int%29

- 1,082
- 2
- 9
- 24
If you mean real full screen (not maximized window), then try setFullScreenWindow(Window w)
method of GraphicsDevice
class.
It is not supported in all systems. Your program can check it by isFullScreenSupported()
of GraphicsDevice
class.
It is more than 10 years when I used this, but if I remember correctly, There is no need to tell resolution to GraphicsDevice
object before entering to the full screen mode. Display will keep the current resolution.
At least there is function getDisplayModes()
in GraphicsDevice
. So your program can select suitable resolution from the list of supported resolution. So there is no need to ask resolution from users.
More information here.

- 8,007
- 2
- 26
- 57