JDK-7177173 : [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7u6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2012-06-14
  • Updated: 2012-08-14
  • Resolved: 2012-07-20
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.
7u6 b20Fixed 8Fixed
Related Reports
Relates :  
Relates :  
Running the code below on JDK 1.6 correctly shows the window maximized across the whole screen. However when running on JDK 1.7 (update 6, build 13) the window is resized to given bounds instead of being maximized.

  JFrame frame = new JFrame();
  frame.setBounds(100, 300, 500, 500);

Note that setting the extended state first and then making the main window visible fixes the problem.


EVALUATION http://hg.openjdk.java.net/hsx/hotspot-comp/jdk/rev/911195d40b89

SUGGESTED FIX http://cr.openjdk.java.net/~anthony/7u6-17-MaximizedBoth-7177173.0/

EVALUATION With a fix for 7142091 the original problem (setVisible(true) followed by an immediate call to setExtendedState()) is no longer reproducible - the extended state will be applied correctly (see the Description for a test case). There's another problem however: we reset the extended state when a window is hidden, and re-apply it when it is shown. When a window is disposed, it's being hidden first. This causes the zoomed state to be reset, and as a result, an event is sent that notifies the application that the extended state is reset. Since Netbeans tracks the state of a window via the events, and preserves the state of a window based on the last event received, the maximized state of NetBeans window cannot be saved into a configuration file because when the window is destroyed, it is always restored back from the maximized state.

EVALUATION We reset state of the window during dispose in CPlatformWindow.deliverZoom().

EVALUATION This is a timing issue related to the fact that the real setVisible() request is dispatched to the EDT on the Mac. If I insert a Thread.sleep(2000) after calling setVisible(true) but before setting the MAXIMIZED_BOTH extended state, the test works just fine.