aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/javax/swing/JApplet.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax/swing/JApplet.java')
-rw-r--r--libjava/classpath/javax/swing/JApplet.java58
1 files changed, 32 insertions, 26 deletions
diff --git a/libjava/classpath/javax/swing/JApplet.java b/libjava/classpath/javax/swing/JApplet.java
index cafb2dabbb8..3ee1046c802 100644
--- a/libjava/classpath/javax/swing/JApplet.java
+++ b/libjava/classpath/javax/swing/JApplet.java
@@ -47,6 +47,7 @@ import java.awt.Graphics;
import java.awt.LayoutManager;
import java.awt.event.KeyEvent;
+import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
/**
@@ -55,8 +56,28 @@ import javax.accessibility.AccessibleContext;
* @author original author unknown
*/
public class JApplet extends Applet
- implements RootPaneContainer
+ implements RootPaneContainer, Accessible
{
+ /**
+ * Provides accessibility support for <code>JApplet</code>.
+ */
+ protected class AccessibleJApplet extends Applet.AccessibleApplet
+ {
+ /**
+ * Creates a new instance of <code>AccessibleJApplet</code>.
+ */
+ public AccessibleJApplet()
+ {
+ super();
+ // Nothing to do here.
+ }
+ }
+
+ /**
+ * The accessible context for this <code>JApplet</code>.
+ */
+ protected AccessibleContext accessibleContext;
+
private static final long serialVersionUID = 7269359214497372587L;
protected JRootPane rootPane;
@@ -64,20 +85,13 @@ public class JApplet extends Applet
/**
* @specnote rootPaneCheckingEnabled is false to comply with J2SE 5.0
*/
- protected boolean rootPaneCheckingEnabled=false;
-
- /**
- * 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;
+ protected boolean rootPaneCheckingEnabled = false;
public JApplet()
{
super.setLayout(new BorderLayout(1, 1));
getRootPane(); // Will do set/create.
- initStageDone = true; // Init stage is now over.
+ setRootPaneCheckingEnabled(true); // Init stage is now over.
}
public Dimension getPreferredSize()
@@ -89,13 +103,8 @@ public class JApplet extends Applet
{
// 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);
}
@@ -155,20 +164,17 @@ public class JApplet extends Applet
{
// 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 JApplet directly. Use "
- + "getContentPane().add() instead");
- getContentPane().add(comp, constraints, index);
- }
+ super.addImpl(comp, constraints, index);
}
public AccessibleContext getAccessibleContext()
{
- return null;
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleJApplet();
+ return accessibleContext;
}
public JMenuBar getJMenuBar()