diff options
author | Roman Kennke <roman@kennke.org> | 2006-06-14 21:07:42 +0000 |
---|---|---|
committer | Roman Kennke <roman@kennke.org> | 2006-06-14 21:07:42 +0000 |
commit | c02ef2edc98e480a94e826fd229dfba12b2e9a00 (patch) | |
tree | 02831cd3967d336febcbc08a535a3c1ee620e7c4 | |
parent | 34a76ebcb67d55cef22c83cfaf18cc81163056b9 (diff) | |
download | classpath-c02ef2edc98e480a94e826fd229dfba12b2e9a00.tar.gz |
2006-06-14 Roman Kennke <kennke@aicas.com>
* javax/swing/plaf/basic/BasicComboBoxUI.java
(getAccessibleChildrenCount): Implemented.
(getAccessibleChild): Implemented.
(isNavigationKey): Implemented.
(KeyHandler.keyPressed): Implemented.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | javax/swing/plaf/basic/BasicComboBoxUI.java | 62 |
2 files changed, 56 insertions, 14 deletions
@@ -1,3 +1,11 @@ +2006-06-14 Roman Kennke <kennke@aicas.com> + + * javax/swing/plaf/basic/BasicComboBoxUI.java + (getAccessibleChildrenCount): Implemented. + (getAccessibleChild): Implemented. + (isNavigationKey): Implemented. + (KeyHandler.keyPressed): Implemented. + 2006-06-14 Andrew John Hughes <gnu_andrew@member.fsf.org> * java/lang/management/ManagementPermission.java: diff --git a/javax/swing/plaf/basic/BasicComboBoxUI.java b/javax/swing/plaf/basic/BasicComboBoxUI.java index 2cb1623cb..c0324a8fb 100644 --- a/javax/swing/plaf/basic/BasicComboBoxUI.java +++ b/javax/swing/plaf/basic/BasicComboBoxUI.java @@ -38,8 +38,6 @@ exception statement from your version. */ package javax.swing.plaf.basic; -import gnu.classpath.NotImplementedException; - import java.awt.Color; import java.awt.Component; import java.awt.Container; @@ -62,6 +60,7 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.accessibility.Accessible; +import javax.accessibility.AccessibleContext; import javax.swing.CellRendererPane; import javax.swing.ComboBoxEditor; import javax.swing.ComboBoxModel; @@ -712,18 +711,51 @@ public class BasicComboBoxUI extends ComboBoxUI return new Dimension(32767, 32767); } + /** + * Returns the number of accessible children of the combobox. + * + * @param c the component (combobox) to check, ignored + * + * @return the number of accessible children of the combobox + */ public int getAccessibleChildrenCount(JComponent c) - throws NotImplementedException { - // FIXME: Need to implement - return 0; + int count = 1; + if (comboBox.isEditable()) + count = 2; + return count; } + /** + * Returns the accessible child with the specified index. + * + * @param c the component, this is ignored + * @param i the index of the accessible child to return + */ public Accessible getAccessibleChild(JComponent c, int i) - throws NotImplementedException { - // FIXME: Need to implement - return null; + Accessible child = null; + switch (i) + { + case 0: // The popup. + if (popup instanceof Accessible) + { + AccessibleContext ctx = ((Accessible) popup).getAccessibleContext(); + ctx.setAccessibleParent(comboBox); + child = (Accessible) popup; + } + break; + case 1: // The editor, if any. + if (comboBox.isEditable() && editor instanceof Accessible) + { + AccessibleContext ctx = + ((Accessible) editor).getAccessibleContext(); + ctx.setAccessibleParent(comboBox); + child = (Accessible) editor; + } + break; + } + return child; } /** @@ -735,10 +767,9 @@ public class BasicComboBoxUI extends ComboBoxUI * @return true if the specified key is a navigation key and false otherwis */ protected boolean isNavigationKey(int keyCode) - throws NotImplementedException { - // FIXME: Need to implement - return false; + return keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN + || keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_RIGHT; } /** @@ -1163,10 +1194,13 @@ public class BasicComboBoxUI extends ComboBoxUI * Invoked whenever key is pressed while JComboBox is in focus. */ public void keyPressed(KeyEvent e) - throws NotImplementedException { - // FIXME: This method calls JComboBox.selectWithKeyChar if the key that - // was pressed is not a navigation key. + if (! isNavigationKey(e.getKeyCode()) && comboBox.isEnabled() + && comboBox.getModel().getSize() != 0) + { + if (comboBox.selectWithKeyChar(e.getKeyChar())) + e.consume(); + } } } |