diff options
Diffstat (limited to 'libjava/classpath/javax/swing/JWindow.java')
-rw-r--r-- | libjava/classpath/javax/swing/JWindow.java | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/libjava/classpath/javax/swing/JWindow.java b/libjava/classpath/javax/swing/JWindow.java index 449900370c6..cc0ac7fd95a 100644 --- a/libjava/classpath/javax/swing/JWindow.java +++ b/libjava/classpath/javax/swing/JWindow.java @@ -60,6 +60,21 @@ import javax.accessibility.AccessibleContext; */ public class JWindow extends Window implements Accessible, RootPaneContainer { + /** + * Provides accessibility support for <code>JWindow</code>. + */ + protected class AccessibleJWindow extends Window.AccessibleAWTWindow + { + /** + * Creates a new instance of <code>AccessibleJWindow</code>. + */ + public AccessibleJWindow() + { + super(); + // Nothing to do here. + } + } + private static final long serialVersionUID = 5420698392125238833L; protected JRootPane rootPane; @@ -71,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()); @@ -113,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() @@ -125,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); } @@ -192,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) @@ -235,7 +233,9 @@ public class JWindow extends Window implements Accessible, RootPaneContainer public AccessibleContext getAccessibleContext() { - return null; + if (accessibleContext == null) + accessibleContext = new AccessibleJWindow(); + return accessibleContext; } protected String paramString() |