2003-12-18 Fernando Nasser <fnasser@redhat.com>
authorfnasser <fnasser@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 19 Dec 2003 02:53:36 +0000 (02:53 +0000)
committerfnasser <fnasser@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 19 Dec 2003 02:53:36 +0000 (02:53 +0000)
        * java/awt/List.java (replaceItem): Prevent selection to move with
        replace and minimize flickering.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@74814 138bc75d-0d04-0410-961f-82ee72b054a4

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

index ecb767c..231cf35 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 23ca34f..79b2faa 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);
+    }
 }
 
 /*************************************************************************/