[cp-patches] FYI: JComponent.getInputMap(int) fix

David Gilbert david.gilbert at object-refinery.com
Tue Jun 6 09:22:49 UTC 2006


This patch (committed) makes the getInputMap(int) method throw an 
IllegalArgumentException for an unrecognised argument, and adds API doc comments:

2006-06-06  David Gilbert  <david.gilbert at object-refinery.com>

	* javax/swing/JComponent.java
	(getInputMap(int)): Throw IllegalArgumentException for unknown
	condition argument, and added API docs,
	(getInputMap()): Added API docs.

I have a Mauve test for this which I'll commit shortly.

Regards,

Dave
-------------- next part --------------
Index: javax/swing/JComponent.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/JComponent.java,v
retrieving revision 1.122
diff -u -r1.122 JComponent.java
--- javax/swing/JComponent.java	19 May 2006 11:35:43 -0000	1.122
+++ javax/swing/JComponent.java	6 Jun 2006 09:11:46 -0000
@@ -2361,6 +2361,19 @@
       }
   }
 
+  /**
+   * Returns the input map associated with this component for the given
+   * state/condition.
+   * 
+   * @param condition  the state (one of {@link #WHEN_FOCUSED}, 
+   *     {@link #WHEN_ANCESTOR_OF_FOCUSED_COMPONENT} and 
+   *     {@link #WHEN_IN_FOCUSED_WINDOW}).
+   * 
+   * @return The input map.
+   * @throws IllegalArgumentException if <code>condition</code> is not one of 
+   *             the specified values.
+   * @since 1.3
+   */
   public final InputMap getInputMap(int condition)
   {
     enableEvents(AWTEvent.KEY_EVENT_MASK);
@@ -2383,10 +2396,20 @@
 
       case UNDEFINED_CONDITION:
       default:
-        return null;
+        throw new IllegalArgumentException("Invalid 'condition' argument: " 
+                                           + condition);
       }
   }
 
+  /**
+   * Returns the input map associated with this component for the 
+   * {@link #WHEN_FOCUSED} state.
+   * 
+   * @return The input map.
+   * 
+   * @since 1.3
+   * @see #getInputMap(int)
+   */
   public final InputMap getInputMap()
   {
     return getInputMap(WHEN_FOCUSED);


More information about the Classpath-patches mailing list