Index: javax/swing/JApplet.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/JApplet.java,v retrieving revision 1.15 diff -u -r1.15 JApplet.java --- javax/swing/JApplet.java 25 Jan 2005 07:07:25 -0000 1.15 +++ javax/swing/JApplet.java 16 Jun 2005 18:50:16 -0000 @@ -55,34 +55,50 @@ private static final long serialVersionUID = 7269359214497372587L; protected JRootPane rootPane; - protected boolean rootPaneCheckingEnabled; + //NOTE: rootPaneCheckingEnabled is false to comply with J2SE 5.0 + protected boolean rootPaneCheckingEnabled=false; + /** boolean tells us if we're in the initialization stage **/ + /** if so, adds go to top-level Container, otherwise they go **/ + /** to the content pane for this container **/ + private boolean init_stage_done=false; + public JApplet() { super.setLayout(new BorderLayout(1, 1)); getRootPane(); // will do set/create + init_stage_done=true; //init stage is now over } - + public Dimension getPreferredSize() { return super.getPreferredSize(); } - + public void setLayout(LayoutManager manager) { - super.setLayout(manager); + /* check if we're in initialization stage. If so, call super.setLayout + otherwise, valid calls go to the content pane */ + if (init_stage_done) + { + if (isRootPaneCheckingEnabled()) + throw new Error("Cannot set layout. Use getContentPane().setLayout() instead."); + getContentPane().setLayout(manager); + } + else + super.setLayout(manager); } - + public void setLayeredPane(JLayeredPane layeredPane) { getRootPane().setLayeredPane(layeredPane); } - + public JLayeredPane getLayeredPane() { return getRootPane().getLayeredPane(); } - + public JRootPane getRootPane() { if (rootPane == null) @@ -94,7 +110,7 @@ { if (rootPane != null) remove(rootPane); - + rootPane = root; add(rootPane, BorderLayout.CENTER); } @@ -126,9 +142,18 @@ protected void addImpl(Component comp, Object constraints, int index) { - super.addImpl(comp, constraints, index); + /* if we're adding the rootPane (initialization stages) use super.add. + otherwise pass the add onto the content pane */ + if (comp == rootPane) + super.addImpl(comp, constraints, index); + else + { + if (isRootPaneCheckingEnabled()) + throw new Error("Do not use add() on JApplet directly.Use getContentPane().add() instead"); + getContentPane().add(comp, constraints, index); + } } - + public AccessibleContext getAccessibleContext() { return null; @@ -156,7 +181,12 @@ public void remove(Component comp) { - getContentPane().remove(comp); + /* if we're removing the root pane, use super.remove. Otherwise + pass it on to the content pane instead */ + if (comp == rootPane) + super.remove(rootPane); + else + getContentPane().remove(comp); } protected boolean isRootPaneCheckingEnabled() Index: javax/swing/JDialog.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/JDialog.java,v retrieving revision 1.12 diff -u -r1.12 JDialog.java --- javax/swing/JDialog.java 13 May 2005 14:06:11 -0000 1.12 +++ javax/swing/JDialog.java 16 Jun 2005 18:50:16 -0000 @@ -70,14 +70,20 @@ protected JRootPane rootPane; /** Whether checking is enabled on the RootPane */ - protected boolean rootPaneCheckingEnabled = true; + /** Should be false to comply with J2SE 5.0 */ + protected boolean rootPaneCheckingEnabled=false; /** The default action taken when closed. */ private int close_action = HIDE_ON_CLOSE; /** Whether JDialogs are decorated by the Look and Feel. */ private static boolean decorated; - + + /** Whether we're in the init stage or not */ + /** If so, adds and layouts are for top-level */ + /** Otherwise they're for the content pane */ + private boolean init_stage_done=false; + /** * Creates a new non-modal JDialog with no title * using a shared Frame as the owner. @@ -224,12 +230,11 @@ protected void dialogInit() { // FIXME: Do a check on GraphicsEnvironment.isHeadless() - setRootPaneCheckingEnabled(false); setLocale(JComponent.getDefaultLocale()); getRootPane(); // will do set/create - setRootPaneCheckingEnabled(true); invalidate(); - + // now that init_stage_done is true, adds and layouts apply to contentPane, not top-level // + init_stage_done=true; } /** @@ -298,11 +303,18 @@ */ public void setLayout(LayoutManager manager) { - if (isRootPaneCheckingEnabled()) - throw new Error("rootPaneChecking is enabled - cannot set layout."); - super.setLayout(manager); + /* check if we're in initialization stage. If so, call super.setLayout + otherwise, valid calls go to the content pane */ + if (init_stage_done) + { + if (isRootPaneCheckingEnabled()) + throw new Error("Cannot set top-level layout. Use getConentPane().setLayout instead.\n"); + getContentPane().setLayout(manager); + } + else + super.setLayout(manager); } - + /** * This method sets the JLayeredPane used in the JDialog. * If the given JLayeredPane is null, then this method @@ -420,11 +432,18 @@ */ protected void addImpl(Component comp, Object constraints, int index) { - if (isRootPaneCheckingEnabled()) - throw new Error("rootPaneChecking is enabled - adding components disallowed."); - super.addImpl(comp, constraints, index); + /* if we're adding the rootPane (initialization stages) use super.add. + otherwise pass the add onto the content pane */ + if (comp == rootPane) + super.addImpl(comp, constraints, index); + else + { + if (isRootPaneCheckingEnabled()) + throw new Error("Do not add directly to JDialog. Use getContentPane().add instead.\n"); + getContentPane().add(comp, constraints, index); + } } - + /** * This method removes a component from the JDialog. * @@ -432,7 +451,8 @@ */ public void remove(Component comp) { - // The path changes if the component == root. + /* if we're removing the root pane, use super.remove. Otherwise + pass it on to the content pane instead */ if (comp == rootPane) super.remove(rootPane); else Index: javax/swing/JFrame.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/JFrame.java,v retrieving revision 1.22 diff -u -r1.22 JFrame.java --- javax/swing/JFrame.java 6 Jun 2005 12:53:44 -0000 1.22 +++ javax/swing/JFrame.java 16 Jun 2005 18:50:16 -0000 @@ -66,8 +66,14 @@ private int close_action = HIDE_ON_CLOSE; protected AccessibleContext accessibleContext; protected JRootPane rootPane; - protected boolean rootPaneCheckingEnabled; - + // NOTE: rootPaneCheckingEnabled is false to comply with J2SE 5.0 */ + protected boolean rootPaneCheckingEnabled=false; + + /** boolean tells us if we're in the initialization stage **/ + /** if so, adds go to top-level Container, otherwise they go **/ + /** to the content pane for this container **/ + private boolean init_stage_done=false; + public JFrame() { super("JFrame"); @@ -116,8 +122,10 @@ super.setLayout(new BorderLayout(1, 1)); enableEvents(AWTEvent.WINDOW_EVENT_MASK); getRootPane(); // will do set/create + /** we're now done the init stage */ + init_stage_done = true; } - + public Dimension getPreferredSize() { return super.getPreferredSize(); @@ -135,9 +143,18 @@ public void setLayout(LayoutManager manager) { - super.setLayout(manager); + /* check if we're in initialization stage. If so, call super.setLayout + otherwise, valid calls go to the content pane */ + if (init_stage_done) + { + if (isRootPaneCheckingEnabled()) + throw new Error("Cannot set layout. Use getContentPane().setLayout() instead."); + getContentPane().setLayout(manager); + } + else + super.setLayout(manager); } - + public void setLayeredPane(JLayeredPane layeredPane) { getRootPane().setLayeredPane(layeredPane); @@ -191,19 +208,33 @@ protected void addImpl(Component comp, Object constraints, int index) { - super.addImpl(comp, constraints, index); + /* if we're adding the rootPane (initialization stages) use super.add. + otherwise pass the add onto the content pane */ + if (comp==rootPane) + super.addImpl(comp, constraints, index); + else + { + if (isRootPaneCheckingEnabled()) + throw new Error("rootPaneChecking is enabled - adding components disallowed."); + getContentPane().add(comp,constraints,index); + } } - + public void remove(Component comp) - { - getContentPane().remove(comp); + { + /* if we're removing the root pane, use super.remove. Otherwise + pass it on to the content pane instead */ + if (comp==rootPane) + super.remove(rootPane); + else + getContentPane().remove(comp); } - + protected boolean isRootPaneCheckingEnabled() { return rootPaneCheckingEnabled; } - + protected void setRootPaneCheckingEnabled(boolean enabled) { rootPaneCheckingEnabled = enabled; Index: javax/swing/JInternalFrame.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/JInternalFrame.java,v retrieving revision 1.16 diff -u -r1.16 JInternalFrame.java --- javax/swing/JInternalFrame.java 27 May 2005 21:12:46 -0000 1.16 +++ javax/swing/JInternalFrame.java 16 Jun 2005 18:50:16 -0000 @@ -431,11 +431,17 @@ protected boolean maximizable; /** Whether the JInternalFrame has rootPaneChecking enabled. */ - protected boolean rootPaneCheckingEnabled = true; - + /** Should be false to comply with J2SE 5.0 */ + protected boolean rootPaneCheckingEnabled=false; + + /** boolean tells us if we're in the initialization stage **/ + /** if so, adds go to top-level Container, otherwise they go **/ + /** to the content pane for this container **/ + private boolean init_stage_done = false; + /** Whether the JInternalFrame is resizable. */ protected boolean resizable; - + /** * The JDesktopIcon that represents the JInternalFrame while it is * iconified. @@ -554,14 +560,11 @@ this.maximizable = maximizable; this.iconable = iconifiable; storedBounds = new Rectangle(); - - setRootPaneCheckingEnabled(false); - setRootPane(createRootPane()); - + setRootPane(createRootPane()); updateUI(); - setRootPaneCheckingEnabled(true); + init_stage_done=true;//done the init stage, now adds go to content pane } - + /** * This method adds Components to this Container. For JInternalFrames, * instead of calling add directly on the JInternalFrame, it should be @@ -576,12 +579,18 @@ */ protected void addImpl(Component comp, Object constraints, int index) { - if (isRootPaneCheckingEnabled()) - throw new Error("Do not use add() on JInternalPane directly. Use getContentPane().add() instead"); - - super.addImpl(comp, constraints, index); + /* if we're adding the rootPane (initialization stages) use super.add. + otherwise pass the add onto the content pane */ + if (comp==rootPane) + super.addImpl(comp,constraints, index); + else + { + if (isRootPaneCheckingEnabled()) + throw new Error("Do not use add() on JInternalFrame directly. Use getContentPane().add() instead"); + getContentPane().add(comp, constraints, index); + } } - + /** * This method adds an InternalFrameListener to this JInternalFrame. * @@ -1181,9 +1190,14 @@ */ public void remove(Component comp) { - super.remove(comp); + /* if we're removing the root pane, use super.remove. Otherwise + pass it on to the content pane instead */ + if (comp==rootPane) + super.remove(comp); + else + getContentPane().remove(comp); } - + /** * This method removes an InternalFrameListener from this JInternalFrame. * @@ -1466,9 +1480,16 @@ */ public void setLayout(LayoutManager manager) { - if (isRootPaneCheckingEnabled()) - throw new Error("Cannot set layout. Use getContentPane().setLayout() instead."); - super.setLayout(manager); + /* check if we're in initialization stage. If so, call super.setLayout + otherwise, valid calls go to the content pane */ + if (init_stage_done) + { + if (isRootPaneCheckingEnabled()) + throw new Error("Cannot set layout. Use getContentPane().setLayout() instead."); + getContentPane().setLayout(manager); + } + else + super.setLayout(manager); } /** Index: javax/swing/JWindow.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/JWindow.java,v retrieving revision 1.17 diff -u -r1.17 JWindow.java --- javax/swing/JWindow.java 25 Jan 2005 07:07:25 -0000 1.17 +++ javax/swing/JWindow.java 16 Jun 2005 18:50:18 -0000 @@ -63,9 +63,15 @@ private static final long serialVersionUID = 5420698392125238833L; protected JRootPane rootPane; - protected boolean rootPaneCheckingEnabled; + //NOTE: rootPaneCheckingEnabled is false to comply with J2SE 5.0 + protected boolean rootPaneCheckingEnabled=false; protected AccessibleContext accessibleContext; - + + /** boolean tells us if we're in the initialization stage **/ + /** if so, adds go to top-level Container, otherwise they go **/ + /** to the content pane for this container **/ + private boolean init_stage_done=false; + public JWindow() { super(SwingUtilities.getOwnerFrame()); @@ -100,6 +106,7 @@ { super.setLayout(new BorderLayout(1, 1)); getRootPane(); // will do set/create + init_stage_done=true; //now we're done init stage, adds and layouts go to content pane } public Dimension getPreferredSize() @@ -109,9 +116,18 @@ public void setLayout(LayoutManager manager) { - super.setLayout(manager); + /* check if we're in initialization stage. If so, call super.setLayout + otherwise, valid calls go to the content pane */ + if (init_stage_done) + { + if (isRootPaneCheckingEnabled()) + throw new Error("Cannot set layout. Use getContentPane().setLayout() instead."); + getContentPane().setLayout(manager); + } + else + super.setLayout(manager); } - + public void setLayeredPane(JLayeredPane layeredPane) { getRootPane().setLayeredPane(layeredPane); @@ -133,7 +149,7 @@ { if (rootPane != null) remove(rootPane); - + rootPane = root; add(rootPane, BorderLayout.CENTER); } @@ -163,14 +179,30 @@ getRootPane().setGlassPane(glassPane); } + protected void addImpl(Component comp, Object constraints, int index) - { - super.addImpl(comp, constraints, index); + { + /* if we're adding the rootPane (initialization stages) use super.add. + otherwise pass the add onto the content pane */ + + if (comp == rootPane) + super.addImpl(comp, constraints, index); + else + { + if (isRootPaneCheckingEnabled()) + throw new Error("Do not use add() on JWindow directly. Use getContentPane().add() instead"); + getContentPane().add(comp, constraints, index); + } } public void remove(Component comp) { - getContentPane().remove(comp); + /* if we're removing the root pane, use super.remove. Otherwise + pass it on to the content pane instead */ + if (comp == rootPane) + super.remove(rootPane); + else + getContentPane().remove(comp); } protected boolean isRootPaneCheckingEnabled()