src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java

Print this page

        

@@ -541,13 +541,35 @@
     @Override
     public int getState() {
         return windowState;
     }
 
+    public Rectangle getMaximizedBounds() {
+        Object target = getTarget();
+        return (target instanceof Frame)
+                ? ((Frame) target).getMaximizedBounds() : null;
+    }
+
+    public Rectangle getDefaultMaximizedBounds() {
+        GraphicsConfiguration config = getGraphicsConfiguration();
+        Insets insets = ((CGraphicsDevice) config.getDevice()).getScreenInsets();
+        Rectangle toBounds = config.getBounds();
+        return new Rectangle(
+                toBounds.x + insets.left,
+                toBounds.y + insets.top,
+                toBounds.width - insets.left - insets.right,
+                toBounds.height - insets.top - insets.bottom);
+    }
+
     @Override
     public void setMaximizedBounds(Rectangle bounds) {
-        // TODO: not implemented
+
+        bounds = (bounds == null)
+                ? getDefaultMaximizedBounds()
+                : constrainBounds(bounds);
+        platformWindow.setMaximizedBounds(
+                bounds.x, bounds.y, bounds.width, bounds.height);
     }
 
     @Override
     public void setBoundsPrivate(int x, int y, int width, int height) {
         setBounds(x, y, width, height, SET_BOUNDS | NO_EMBEDDED_CHECK);

@@ -1056,10 +1078,16 @@
     @Override
     public final void displayChanged() {
         if (updateGraphicsDevice()) {
             updateMinimumSize();
         }
+
+        Rectangle maximizedBounds = getMaximizedBounds();
+        if (maximizedBounds == null) {
+            setMaximizedBounds(getDefaultMaximizedBounds());
+        }
+
         // Replace surface unconditionally, because internal state of the
         // GraphicsDevice could be changed.
         replaceSurfaceData();
         repaintPeer();
     }