aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
authorFernando Nasser <fnasser@redhat.com>2003-12-19 02:53:36 +0000
committerFernando Nasser <fnasser@gcc.gnu.org>2003-12-19 02:53:36 +0000
commitd416de057b728ba3bcde18362eb59be27305af7a (patch)
treeb464e8e7a76f9704ee26827f12448545c4fdd3f2 /libjava/java
parent6310608457fbe00ebbf6cc2505044fc134c396c2 (diff)
downloadgcc-d416de057b728ba3bcde18362eb59be27305af7a.zip
gcc-d416de057b728ba3bcde18362eb59be27305af7a.tar.gz
gcc-d416de057b728ba3bcde18362eb59be27305af7a.tar.bz2
List.java (replaceItem): Prevent selection to move with replace and minimize flickering.
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
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/awt/List.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/libjava/java/awt/List.java b/libjava/java/awt/List.java
index 23ca34f..79b2faa 100644
--- a/libjava/java/awt/List.java
+++ b/libjava/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);
+ }
}
/*************************************************************************/