How to avoid overlapping of windows created by Processing with Windows 8 toolbar?
App sets window size with size()
Makes window resizable with surface.setResizable(true)
Monitors Processing’s width/height variables and saves them in settings file
When run again, size is restored.
Unfortunately, if the user has previously maximized the window (which leaves the toolbar free), Processing opens the window at a slightly different position. It overlaps the toolbar.
To add to this, if I save the window’s position (to use my own positioning code, i.e. to save and restore window positions) with:
javax.swing.JFrame jframe = (javax.swing.JFrame)((processing.awt.PSurfaceAWT.SmoothCanvas)getSurface().getNative()).getFrame();
Window_X = jframe.getX(); // result -8 for window at top-left position
Window_Y = jframe.getY(); // result -8 for window at top-left position
… and restore it with surface.setLocation(), then the position is wrong. To have the window appear at the top-left position of the screen, I have to empirically do surface.setLocation(5, 5), not surface.setLocation(-8, -8); This upgrade …
[when window coordinates are read with jframe.getX/Y and restored with surface.setLocation()] the position is wrong
To clarify, this does not always lead to a wrong window position:
jframe.getX() and jframe.getY() return correct coordinates if the window is moved and resized with the mouse. Correct meaning that these coordinates (5|5) could be used with surface.setLocation to restore the position.
But if the window is maximized with a double click into the title bar, jframe.getX()/jframe.getY() return values that make no sense (-8|-8) and do not work with surface.setLocation.