JDK-8007219 : [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7u9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2013-01-30
  • Updated: 2015-08-21
  • Resolved: 2013-10-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 Other
8 b112Fixed openjdk7uFixed
Related Reports
Cloners :  
Cloners :  
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64

A DESCRIPTION OF THE PROBLEM :
If the size of a JFrame is within 10 x 10 pixels of the available screen bounds then setting the framestate to Frame.MAXIMIZED_BOTH actually MINIMIZES the JFrame.

REGRESSION.  Regression from Apple's Java 6uX

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached code snippet and observe that the JFrame is minimized when the frame state is set to Frame.MAXIMIZED_BOTH.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JFrame stays at existing size
ACTUAL -
JFrame is minimized as much as the minimum layout size allows

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;

public class MFrameMaximizationBugReport {
  public static void main(final String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        final JFrame frame = new JFrame("Frame");
        
        final JLabel label = new JLabel("Hello world!");
        label.setFont(label.getFont().deriveFont(48.0f));
        label.setBorder(new CompoundBorder(new EmptyBorder(15, 15, 15, 15), label.getBorder()));
        
        frame.add(label);

        final Toolkit toolkit = Toolkit.getDefaultToolkit();
        final GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
        final GraphicsDevice graphicsDevice = graphicsEnvironment.getDefaultScreenDevice();
        
        final Dimension screenSize = toolkit.getScreenSize();
        final Insets screenInsets = toolkit.getScreenInsets(graphicsDevice.getDefaultConfiguration());
        
        final Rectangle availableScreenBounds = new Rectangle(screenSize);
        
        availableScreenBounds.x += screenInsets.left;
        availableScreenBounds.y += screenInsets.top;
        availableScreenBounds.width -= (screenInsets.left + screenInsets.right);
        availableScreenBounds.height -= (screenInsets.top + screenInsets.bottom);
        
        frame.setBounds(availableScreenBounds.x, availableScreenBounds.y, availableScreenBounds.width, availableScreenBounds.height);
        
        frame.setExtendedState(frame.getExtendedState() | Frame.MAXIMIZED_BOTH);
        
        frame.setVisible(true);
      }
    });
  }
}

---------- END SOURCE ----------
Comments
isn't a regression from jdk8 pov (even not a regression from 7 GA - 7u6 on Mac OS X)
02-10-2013

Setting maximal size to a frame leads that NSWindow is in zoomed state and next zoom call makes frame minimized.
10-09-2013