diff options
Diffstat (limited to 'javax/swing/JWindow.java')
-rw-r--r-- | javax/swing/JWindow.java | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/javax/swing/JWindow.java b/javax/swing/JWindow.java index 1a7cad488..cc0ac7fd9 100644 --- a/javax/swing/JWindow.java +++ b/javax/swing/JWindow.java @@ -86,13 +86,6 @@ public class JWindow extends Window implements Accessible, RootPaneContainer protected AccessibleContext accessibleContext; - /** - * 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 initStageDone = false; - public JWindow() { super(SwingUtilities.getOwnerFrame()); @@ -128,7 +121,7 @@ public class JWindow extends Window implements Accessible, RootPaneContainer super.setLayout(new BorderLayout(1, 1)); getRootPane(); // will do set/create // Now we're done init stage, adds and layouts go to content pane. - initStageDone = true; + setRootPaneCheckingEnabled(true); } public Dimension getPreferredSize() @@ -140,13 +133,8 @@ public class JWindow extends Window implements Accessible, RootPaneContainer { // Check if we're in initialization stage. If so, call super.setLayout // otherwise, valid calls go to the content pane. - if (initStageDone) - { - if (isRootPaneCheckingEnabled()) - throw new Error("Cannot set layout. Use getContentPane().setLayout()" - + " instead."); - getContentPane().setLayout(manager); - } + if (isRootPaneCheckingEnabled()) + getContentPane().setLayout(manager); else super.setLayout(manager); } @@ -207,15 +195,10 @@ public class JWindow extends Window implements Accessible, RootPaneContainer { // If we're adding in the initialization stage use super.add. // otherwise pass the add onto the content pane. - if (!initStageDone) - super.addImpl(comp, constraints, index); + if (isRootPaneCheckingEnabled()) + getContentPane().add(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); - } + super.addImpl(comp, constraints, index); } public void remove(Component comp) |