summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--java/awt/List.java17
2 files changed, 20 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 9de803d30..0043bd0fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-12-26 Fernando Nasser <fnasser@redhat.com>
+
+ * java/awt/List.java (replaceItem): Prevent selection to move with
+ replace and minimize flickering.
+
2003-12-26 Michael Koch <konqueror@gmx.de>
* native/target/generic/target_generic_file.h
diff --git a/java/awt/List.java b/java/awt/List.java
index 23ca34fab..79b2faa62 100644
--- a/java/awt/List.java
+++ b/java/awt/List.java
@@ -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);
+ }
}
/*************************************************************************/