United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-7177173 : [macosx] JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH) not working as expected in JDK 7

Details
Type:
Bug
Submit Date:
2012-06-14
Status:
Closed
Updated Date:
2012-08-14
Project Name:
JDK
Resolved Date:
2012-07-20
Component:
client-libs
OS:
os_x
Sub-Component:
javax.swing
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
7u6
Fixed Versions:
7u6 (b20)

Related Reports
Backport:
Relates:
Relates:

Sub Tasks

Description
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);
  frame.setVisible(true);
  frame.setExtendedState(frame.MAXIMIZED_BOTH);

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

http://netbeans.org/bugzilla/show_bug.cgi?id=214056

                                    

Comments
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-comp/jdk/rev/911195d40b89
                                     
2012-08-14
SUGGESTED FIX

http://cr.openjdk.java.net/~anthony/7u6-17-MaximizedBoth-7177173.0/
                                     
2012-07-06
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.
                                     
2012-06-28
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.
                                     
2012-06-20
EVALUATION

We reset state of the window during dispose in CPlatformWindow.deliverZoom().
                                     
2012-06-20



Hardware and Software, Engineered to Work Together