List.java (replaceItem): Prevent selection to move with replace and minimize flickering.
authorFernando Nasser <fnasser@redhat.com>
Fri, 19 Dec 2003 02:53:36 +0000 (02:53 +0000)
committerFernando Nasser <fnasser@gcc.gnu.org>
Fri, 19 Dec 2003 02:53:36 +0000 (02:53 +0000)
2003-12-18  Fernando Nasser  <fnasser@redhat.com>

        * java/awt/List.java (replaceItem): Prevent selection to move with
        replace and minimize flickering.

From-SVN: r74814

libjava/ChangeLog
libjava/java/awt/List.java

index ecb767c01c6249800a8d1b851c36b34aec1c6d9d..231cf35a752e4bbcf6cfcd206877d83bf7ef1d17 100644 (file)
@@ -1,3 +1,8 @@
+2003-12-18  Fernando Nasser  <fnasser@redhat.com>
+
+       * java/awt/List.java (replaceItem): Prevent selection to move with
+       replace and minimize flickering.
 2003-12-18  Michael Koch  <konqueror@gmx.de>
 
        * libltdl/ltdl.c: Define __private_extern__ if needed.
index 23ca34fab0c6b3a7479d6634d68aa0d082571226..79b2faa62994525d436324ae22050011b51c8c8e 100644 (file)
@@ -647,8 +647,21 @@ clear()
 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);
+    }
 }
 
 /*************************************************************************/