< prev index next >
src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java
Print this page
@@ -541,13 +541,42 @@
@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);
+ }
+
+ private void updateMaximizedBounds() {
+ Rectangle maximizedBounds = getMaximizedBounds();
+ if (maximizedBounds == null) {
+ setMaximizedBounds(getDefaultMaximizedBounds());
+ }
}
@Override
public void setBoundsPrivate(int x, int y, int width, int height) {
setBounds(x, y, width, height, SET_BOUNDS | NO_EMBEDDED_CHECK);
@@ -633,10 +662,14 @@
// First, update peer's bounds
setBounds(x, y, w, h, SET_BOUNDS, false, false);
// Second, update the graphics config and surface data
final boolean isNewDevice = updateGraphicsDevice();
+ if (isNewDevice) {
+ updateMaximizedBounds();
+ }
+
if (resized || isNewDevice) {
replaceSurfaceData();
updateMinimumSize();
}
@@ -1056,10 +1089,13 @@
@Override
public final void displayChanged() {
if (updateGraphicsDevice()) {
updateMinimumSize();
}
+
+ updateMaximizedBounds();
+
// Replace surface unconditionally, because internal state of the
// GraphicsDevice could be changed.
replaceSurfaceData();
repaintPeer();
}
< prev index next >