Starting a Desktop App Maximized
I have a cross-platform SingleFrameApplication for Mac, Windows, and Linux.
It needs to start Maximized but when Normalized, revert to the last-saved session size. In startup I'm using the code:
// Resize application to full screen. Can't find a way to do this in advance.
getMainFrame().setExtendedState(getMainFrame().getExtendedState() | Frame.MAXIMIZED_BOTH);
In the willExit handler I use the complementary code:
getMainFrame().setExtendedState(getMainFrame().getExtendedState() & ~Frame.MAXIMIZED_BOTH);
This allows the normal size to be saved in the session.
This works, but the start in normal size is visible. The frame then maximizes. With most video drivers the difference between the normal size and maximized size is black while the rest of the window is white for a fraction of a second while the window redraws. When shutting down, you can also see the window shrink before it disappears.
This is all very distracting.
If I put the MAXIMIZE code _before_ show, it doesn't work. THe implementation makes it obvious why.
Is there a way to get the functionality I've described without all the artifacts?