I'm attempting to implement a Full Screen option in my Java app (user request).
I've tried this:
private void toggleFullScreen() {
dispose();
setUndecorated(true);
setExtendedState(MAXIMIZED_BOTH);
setVisible(true);
}
and this:
private void toggleFullScreen() {
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
dispose();
setUndecorated(true);
gd.setFullScreenWindow(this);
setVisible(true);
}
I get the "frame is displayable" error from setUndecorated(), hence the use of dispose() and setVisible(true). However, the result of the above is that the app opens for a split second and then disappears.
Any ideas what might be going wrong?
Happy to link to the source repo if anyone can help.