Hey,

Again, the constructor mauve test for JMenu that I wrote had many
constructor regressions.  One of them caused me to look more closely at
the remove(int) method and make a couple of changes.  I have committed a
mauve test for these changes (remove.java).  Could someone please
approve this patch so that I can commit it.  Thanks.

Here is the Changelog entry:

2006-06-20  Tania Bento  <[EMAIL PROTECTED]>

        * javax/swing/JMenu.java
        (remove): An IllegalArgumentException should be thrown if
        either index < 0 or if index > 0 and there are no menu
        components. Also, a check was added that ensures there are
        menu components before removing the desired the component.

Cheers,
Tania
Index: JMenu.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JMenu.java,v
retrieving revision 1.27
diff -u -r1.27 JMenu.java
--- JMenu.java	16 May 2006 06:49:32 -0000	1.27
+++ JMenu.java	20 Jun 2006 21:28:57 -0000
@@ -219,7 +226,11 @@
    */
   public void remove(int index)
   {
-    popupMenu.remove(index);
+    if (index < 0 || (index > 0 && getMenuComponentCount() == 0))
+      throw new IllegalArgumentException();
+  
+    if (getMenuComponentCount() > 0)
+      popupMenu.remove(index);
   }
 
   /**

Reply via email to