Hey,

This patch modifies the remove(int) method.  It now makes classpath pass
a couple of failing Intel tests.  I have a mauve test for the remove
method and will be committing it after I commit this patch.

2006-08-01  Tania Bento   <[EMAIL PROTECTED]>

        * java/awt/Choice.java
        (remove(int)): An IllegalArgumentException should not be thrown
        if int is invalid.  Update selectedIndex and peer selection.

Cheers,
Tania
Index: java/awt/Choice.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/Choice.java,v
retrieving revision 1.28
diff -u -r1.28 Choice.java
--- java/awt/Choice.java	30 Jul 2006 09:01:33 -0000	1.28
+++ java/awt/Choice.java	1 Aug 2006 16:14:39 -0000
@@ -320,9 +320,6 @@
    */
   public synchronized void remove(int index)
   {
-    if ((index < 0) || (index > getItemCount()))
-      throw new IllegalArgumentException("Bad index: " + index);
-
     pItems.removeElementAt(index);
 
     if (peer != null)
@@ -334,11 +331,16 @@
       {
 	if( index == selectedIndex )
 	  {
-	    if( peer != null ) 
+	    if( peer != null )
 	      ((ChoicePeer)peer).select( 0 ); // force an event here
+            selectedIndex = 0;
 	  }
 	else if( selectedIndex > index )
-	  select( selectedIndex - 1 );
+          {
+            if ( peer != null)
+              ((ChoicePeer)peer).select(selectedIndex - 1);
+	    select( selectedIndex - 1 );
+          }
       }
 
   }

Reply via email to