JDK-6684922 : Setting maximized state of JFrame still does not work properly
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-04-07
  • Updated: 2011-01-19
  • Resolved: 2008-04-18
Related Reports
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_05-ea"
Java(TM) SE Runtime Environment (build 1.6.0_05-ea-b05)
Java HotSpot(TM) Client VM (build 1.6.0_05-ea-b05, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
Initial setting the maximized state of JFrame does still not work, if the content pane is set or a component is added to the content pane.
This bug report is similar to bug report Id 4464714, except the setting of the content pane.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run example source code.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The frame should appear in maximized state.
ACTUAL -
The frame appears in normal state.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;

public class Maxim extends JFrame {

	public Maxim() {
		super();
		JPanel content =new JPanel();
		setContentPane(content);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setExtendedState(MAXIMIZED_BOTH);
	}

	public static void main(String args[]){

		// thread safe packing
		Runnable show = new Runnable() {
			public void run() {
				Maxim mf = new Maxim();
				mf.pack();
				mf.setVisible(true);
				//mf.setExtendedState(MAXIMIZED_BOTH);
			}
		};
		SwingUtilities.invokeLater(show);
	}
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Call setExtendedState(MAXIMIZED_BOTH) after showing the frame.