The way I got it working (clean and fast) was to NOT extend JFrame (like GameFrame) and maintain 2 protected JFrames. The other key was to remove the Insets for the Windowed frame, as below (an extension of JFrame that has this method):

One slight problem with this is that the Insets are not set if you call:

Ok, I got it working. I had been trying to extend JFrame and either modify it or use it with another protected instance of JFrame.

I looked over the Balls.jar example a few times, and couldn't find where setFullScreen was actually doing anything. I realized that SOME of the source files were not included. Using FrontEndPlus, I reversed the other class files (specifically GameFrame), and saw where those changes were.

The way I got it working (clean and fast) was to NOT extend JFrame (like GameFrame) and maintain 2 protected JFrames. The other key was to remove the Insets for the Windowed frame, as below (an extension of JFrame that has this method):

I would like to say, for any Sun developers who might be watching this, that I think it would be of great benefit (and cleanness of code) to be able to toggle between fullscreen and windowed modes on a single JFrame. The gfxDevice.setFullScreen(boolean) does not allow for this because of the inability to call setUndecorated(boolean) after the Peer has been created (without calling removeNotify/addNotify).

I have a test, which is a derivative from the infamous Balls,which automatically changes to and from fullscreen mode for all display modes available, and that thing runs through a whole night of switching.. =)

You know, I tried the original Balls.jar, and it worked OK -- but windowed mode was still fullscreen (ie: no decorations)....

I've looked through the various JavaGaming posts (including the Balls.jar example) and the Java Forums. I can't seem to find any information on how to correctly toggle between Fullscreen (and undecorated) and Windowed (and decorated) modes.

I have tried a few different ways. I have tried using 2 JFrames (one decorated and one not) as well as using the addNotify/removeNotify so that I could call setUndecorated on a single JFrame. In either case, it sometimes goes blank when switching back into Fullscreen, even though the Active Rendering loop continues to process.

Does anyone have a simplistic example of how to switch back and forth between the two modes?

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org