JDK-6365898 : Frame.setExtendedState(Frame.MAXIMIZED_BOTH) doesn't work well on Linux
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2005-12-21
  • Updated: 2011-03-07
  • Resolved: 2011-03-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 7
7 b14Fixed
Related Reports
Relates :  
Relates :  
Description
If you set extended state to MAXIMAZED_BOTH before showing frame
it will be shown in normal state on Linux (the same program works
well on Windows).  The test fails with 1.4.2 and later (have not tried earlier
versions)
import java.awt.Frame;

public class ext_state_test {
    public static void main(String[] args) {
        Frame f = new Frame("");
        f.setExtendedState(Frame.MAXIMIZED_BOTH); // interchange with following line
        f.setVisible(true);
    }
}

Comments
SUGGESTED FIX $ sccs diffs -C XFramePeer.java ------- XFramePeer.java ------- *** /tmp/sccs.g995ol 2007-05-24 16:05:18.000000000 +0400 --- XFramePeer.java 2007-05-24 15:43:51.000000000 +0400 *************** *** 59,65 **** super.preInit(params); Frame target = (Frame)(this.target); // set the window attributes for this Frame ! winAttr.initialState = target.getState(); state = 0; undecorated = Boolean.valueOf(target.isUndecorated()); winAttr.nativeDecor = !target.isUndecorated(); --- 59,65 ---- super.preInit(params); Frame target = (Frame)(this.target); // set the window attributes for this Frame ! winAttr.initialState = target.getExtendedState(); state = 0; undecorated = Boolean.valueOf(target.isUndecorated()); winAttr.nativeDecor = !target.isUndecorated();
24-05-2007

EVALUATION The bug is caused by the fact that the initial state is retrieved using the target.getState() instead of the target.getExtendedState(). The former one may only return whether the frame is in normal or iconified state. However, extended states (such as MAXIMIZED state) can be found out by using getExtendedState() method only.
24-05-2007