diff options
author | Michael Koch <konqueror@gmx.de> | 2003-12-26 17:09:17 +0000 |
---|---|---|
committer | Michael Koch <konqueror@gmx.de> | 2003-12-26 17:09:17 +0000 |
commit | 2b4bb26e5b12b535dbc63276c0127630e7597f9c (patch) | |
tree | 3399a4ba78bd30c593a107d1b305662b3b548205 /java/awt/List.java | |
parent | 045fa59c437a9cd426ab4af7fc6ad0c37f6c3423 (diff) | |
download | classpath-2b4bb26e5b12b535dbc63276c0127630e7597f9c.tar.gz |
2003-12-26 Fernando Nasser <fnasser@redhat.com>
* java/awt/List.java (replaceItem): Prevent selection to move with
replace and minimize flickering.
Diffstat (limited to 'java/awt/List.java')
-rw-r--r-- | java/awt/List.java | 17 |
1 files changed, 15 insertions, 2 deletions
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); + } } /*************************************************************************/ |