From ad59a54fa8f8f0b39dedfc7cafce276d867d073f Mon Sep 17 00:00:00 2001 From: fros4943 Date: Wed, 23 May 2007 09:10:15 +0000 Subject: [PATCH] fix: maximized cooja frame overlapping os display regions (such as win start menu). --- tools/cooja/java/se/sics/cooja/GUI.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/GUI.java b/tools/cooja/java/se/sics/cooja/GUI.java index b1eebc4aa..667702b81 100644 --- a/tools/cooja/java/se/sics/cooja/GUI.java +++ b/tools/cooja/java/se/sics/cooja/GUI.java @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 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; @@ -552,10 +552,15 @@ public class GUI { // Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); + Rectangle maxSize = GraphicsEnvironment.getLocalGraphicsEnvironment() + .getMaximumWindowBounds(); // Create and set up the window. frame = new JFrame("COOJA Simulator"); + if (maxSize != null) + frame.setMaximizedBounds(maxSize); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + logger.debug(frame.getPreferredSize()); // Create and set up the content pane. JDesktopPane desktop = new JDesktopPane(); @@ -565,7 +570,7 @@ public class GUI { JComponent newContentPane = gui.getDesktopPane(); newContentPane.setOpaque(true); frame.setContentPane(newContentPane); - + frame.setSize(700, 700); frame.setLocationRelativeTo(null); frame.addWindowListener(gui.guiEventHandler); @@ -579,6 +584,15 @@ public class GUI { if (framePosX >= 0 && framePosY >= 0 && frameWidth > 0 && frameHeight > 0) { frame.setLocation(framePosX, framePosY); 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); + } } }