fix: maximized cooja frame overlapping os display regions (such as win start menu).

This commit is contained in:
fros4943 2007-05-23 09:10:15 +00:00
parent 55a255bb9c
commit ad59a54fa8

View File

@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $Id: GUI.java,v 1.49 2007/05/19 17:05:54 fros4943 Exp $ * $Id: GUI.java,v 1.50 2007/05/23 09:10:15 fros4943 Exp $
*/ */
package se.sics.cooja; package se.sics.cooja;
@ -552,10 +552,15 @@ public class GUI {
// Make sure we have nice window decorations. // Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(true); JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true);
Rectangle maxSize = GraphicsEnvironment.getLocalGraphicsEnvironment()
.getMaximumWindowBounds();
// Create and set up the window. // Create and set up the window.
frame = new JFrame("COOJA Simulator"); frame = new JFrame("COOJA Simulator");
if (maxSize != null)
frame.setMaximizedBounds(maxSize);
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
logger.debug(frame.getPreferredSize());
// Create and set up the content pane. // Create and set up the content pane.
JDesktopPane desktop = new JDesktopPane(); JDesktopPane desktop = new JDesktopPane();
@ -565,7 +570,7 @@ public class GUI {
JComponent newContentPane = gui.getDesktopPane(); JComponent newContentPane = gui.getDesktopPane();
newContentPane.setOpaque(true); newContentPane.setOpaque(true);
frame.setContentPane(newContentPane); frame.setContentPane(newContentPane);
frame.setSize(700, 700); frame.setSize(700, 700);
frame.setLocationRelativeTo(null); frame.setLocationRelativeTo(null);
frame.addWindowListener(gui.guiEventHandler); frame.addWindowListener(gui.guiEventHandler);
@ -579,6 +584,15 @@ public class GUI {
if (framePosX >= 0 && framePosY >= 0 && frameWidth > 0 && frameHeight > 0) { if (framePosX >= 0 && framePosY >= 0 && frameWidth > 0 && frameHeight > 0) {
frame.setLocation(framePosX, framePosY); frame.setLocation(framePosX, framePosY);
frame.setSize(frameWidth, frameHeight); frame.setSize(frameWidth, frameHeight);
// Assume window was maximized if loaded size matches maximum bounds
if (maxSize != null
&& framePosX == 0
&& framePosY == 0
&& frameWidth == maxSize.width
&& frameHeight == maxSize.height) {
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
}
} }
} }