summaryrefslogtreecommitdiff
path: root/javax/swing/JComponent.java
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2006-04-06 10:15:33 +0000
committerRoman Kennke <roman@kennke.org>2006-04-06 10:15:33 +0000
commitcf5f4ad0f5af487d1a311ac13c396fa5e557a32d (patch)
treec556dcdf86905c98da9012847557e7d0bf7ffbcd /javax/swing/JComponent.java
parentb78043a5d284c6a530cc59dee6cb3214762bd05a (diff)
downloadclasspath-cf5f4ad0f5af487d1a311ac13c396fa5e557a32d.tar.gz
2006-04-06 Roman Kennke <kennke@aicas.com>
* java/awt/Component.java (AccessibleAWTComponent.getAccessibleStateSet): Don't handle opaque state here. This is only done in JComponent. * javax/swing/JComponent.java (AccessibleJComponent.getAccessibleStateSet): Handle opaque flag here. (getNextFocusableComponent): Implemented stub method. (grabFocus): Implemented stub method. (unregisterKeyboardAction): Implemented stub method. (setNextFocusableComponent): Implemented stub method. * javax/swing/CompatibilityFocusTraversalPolicy.java: New file. This is a helper class for providing compatibility with the older Swing focus API.
Diffstat (limited to 'javax/swing/JComponent.java')
-rw-r--r--javax/swing/JComponent.java60
1 files changed, 52 insertions, 8 deletions
diff --git a/javax/swing/JComponent.java b/javax/swing/JComponent.java
index b15840939..e025fe877 100644
--- a/javax/swing/JComponent.java
+++ b/javax/swing/JComponent.java
@@ -337,10 +337,14 @@ public abstract class JComponent extends Container implements Serializable
*/
public AccessibleStateSet getAccessibleStateSet()
{
- // TODO: The only JComponent property that is (theoretically) handled
- // here seems to be 'opaque'. However, we already handle this in
- // AccessibleAWTComponent and do not need to handle it here too.
- return super.getAccessibleStateSet();
+ // Note: While the java.awt.Component has an 'opaque' property, it
+ // seems that it is not added to the accessible state set there, even
+ // if this property is true. However, it is handled for JComponent, so
+ // we add it here.
+ AccessibleStateSet state = super.getAccessibleStateSet();
+ if (isOpaque())
+ state.add(AccessibleState.OPAQUE);
+ return state;
}
/**
@@ -1393,7 +1397,12 @@ public abstract class JComponent extends Container implements Serializable
*/
public Component getNextFocusableComponent()
{
- return null;
+ Container focusRoot = this;
+ if (! this.isFocusCycleRoot())
+ focusRoot = getFocusCycleRootAncestor();
+
+ FocusTraversalPolicy policy = focusRoot.getFocusTraversalPolicy();
+ return policy.getComponentAfter(focusRoot, this);
}
/**
@@ -1587,7 +1596,7 @@ public abstract class JComponent extends Container implements Serializable
*/
public void grabFocus()
{
- // TODO: Implement this properly.
+ requestFocus();
}
/**
@@ -2575,7 +2584,20 @@ public abstract class JComponent extends Container implements Serializable
*/
public void unregisterKeyboardAction(KeyStroke aKeyStroke)
{
- // FIXME: Must be implemented.
+ ActionMap am = getActionMap();
+ // This loops through the conditions WHEN_FOCUSED,
+ // WHEN_ANCESTOR_OF_FOCUSED_COMPONENT and WHEN_IN_FOCUSED_WINDOW.
+ for (int cond = 0; cond < 3; cond++)
+ {
+ InputMap im = getInputMap(cond);
+ if (im != null)
+ {
+ Object action = im.get(aKeyStroke);
+ if (action != null && am != null)
+ am.remove(action);
+ im.remove(aKeyStroke);
+ }
+ }
}
@@ -2853,7 +2875,29 @@ public abstract class JComponent extends Container implements Serializable
*/
public void setNextFocusableComponent(Component aComponent)
{
- // TODO: Implement this properly.
+ Container focusRoot = this;
+ if (! this.isFocusCycleRoot())
+ focusRoot = getFocusCycleRootAncestor();
+
+ FocusTraversalPolicy policy = focusRoot.getFocusTraversalPolicy();
+ if (policy instanceof CompatibilityFocusTraversalPolicy)
+ {
+ policy = new CompatibilityFocusTraversalPolicy(policy);
+ focusRoot.setFocusTraversalPolicy(policy);
+ }
+ CompatibilityFocusTraversalPolicy p =
+ (CompatibilityFocusTraversalPolicy) policy;
+
+ Component old = getNextFocusableComponent();
+ if (old != null)
+ {
+ p.removeNextFocusableComponent(this, old);
+ }
+
+ if (aComponent != null)
+ {
+ p.addNextFocusableComponent(this, aComponent);
+ }
}
/**