Again, this will make JAPI a little bit more happy. 2006-06-14 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/plaf/basic/BasicComboBoxUI.java (getAccessibleChildrenCount): Implemented. (getAccessibleChild): Implemented. (isNavigationKey): Implemented. (KeyHandler.keyPressed): Implemented. /Roman -- “Improvement makes straight roads, but the crooked roads, without Improvement, are roads of Genius.” - William Blake
Index: javax/swing/plaf/basic/BasicComboBoxUI.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java,v retrieving revision 1.37 diff -u -1 -0 -r1.37 BasicComboBoxUI.java --- javax/swing/plaf/basic/BasicComboBoxUI.java 13 Jun 2006 09:28:57 -0000 1.37 +++ javax/swing/plaf/basic/BasicComboBoxUI.java 14 Jun 2006 21:04:11 -0000 @@ -31,22 +31,20 @@ independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this 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; import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics; import java.awt.Insets; import java.awt.LayoutManager; import java.awt.Rectangle; import java.awt.event.FocusEvent; @@ -55,20 +53,21 @@ import java.awt.event.ItemListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; 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; import javax.swing.DefaultListCellRenderer; import javax.swing.InputMap; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JList; import javax.swing.ListCellRenderer; @@ -705,47 +704,79 @@ * * @param c The [EMAIL PROTECTED] JComponent} to find the maximum size for * * @return The maximum size (<code>Dimension(32767, 32767)</code>). */ public Dimension getMaximumSize(JComponent c) { 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; } /** * Returns true if the specified key is a navigation key and false otherwise * * @param keyCode a key for which to check whether it is navigation key or * not. * * @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; } /** * Selects next possible item relative to the current selection * to be next selected item in the combo box. */ protected void selectNextPossibleValue() { int index = comboBox.getSelectedIndex(); if (index != comboBox.getItemCount() - 1) @@ -1156,24 +1187,27 @@ { public KeyHandler() { // Nothing to do here. } /** * 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(); + } } } /** * Handles the changes occurring in the JComboBox's data model. */ public class ListDataHandler extends Object implements ListDataListener { /** * Creates a new ListDataHandler object.
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil