Index: ChangeLog =================================================================== RCS file: /cvsroot/classpath/classpath/ChangeLog,v retrieving revision 1.1700 diff -u -b -B -r1.1700 ChangeLog --- ChangeLog 26 Dec 2003 16:55:53 -0000 1.1700 +++ ChangeLog 26 Dec 2003 17:08:48 -0000 @@ -1,3 +1,8 @@ +2003-12-26 Fernando Nasser + + * java/awt/List.java (replaceItem): Prevent selection to move with + replace and minimize flickering. + 2003-12-26 Michael Koch * native/target/generic/target_generic_file.h Index: java/awt/List.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/awt/List.java,v retrieving revision 1.16 diff -u -b -B -r1.16 List.java --- java/awt/List.java 3 Dec 2003 08:20:04 -0000 1.16 +++ java/awt/List.java 26 Dec 2003 17:08:48 -0000 @@ -647,8 +647,21 @@ public synchronized void replaceItem(String item, int index) throws IllegalArgumentException { - remove(index); - addItem(item, index); + if ((index < 0) || (index >= items.size())) + throw new IllegalArgumentException("Bad list index: " + index); + + items.insertElementAt(item, index + 1); + items.removeElementAt (index); + + if (peer != null) + { + ListPeer l = (ListPeer) peer; + + /* We add first and then remove so that the selected + item remains the same */ + l.add (item, index + 1); + l.delItems (index, index); + } } /*************************************************************************/