diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | javax/swing/DefaultListSelectionModel.java | 10 | ||||
-rw-r--r-- | javax/swing/JList.java | 2 |
3 files changed, 18 insertions, 6 deletions
@@ -1,3 +1,15 @@ +2005-10-20 Anthony Balkissoon <abalkiss@redhat.com> + + * javax/swing/DefaultListSelectionModel.java: + (setLeadSelectionIndex): If the selection mode is SINGLE_SELECTION then + pass this call to setSelectionInterval. + (addSelectionInterval): If the selection mode is SINGLE_SELECTION then + pass the call to setSelectionInterval and avoid the lengthy checks + that don't apply to this mode. + * javax/swing/JList.java: + (getSelectedIndices): Changed bounds of for loop to include the + maxSelectionIndex. + 2005-10-20 Lillian Angel <langel@redhat.com> * examples/gnu/classpath/examples/swing/Demo.java diff --git a/javax/swing/DefaultListSelectionModel.java b/javax/swing/DefaultListSelectionModel.java index 572856fa7..09388f588 100644 --- a/javax/swing/DefaultListSelectionModel.java +++ b/javax/swing/DefaultListSelectionModel.java @@ -238,6 +238,9 @@ public class DefaultListSelectionModel implements Cloneable, */ public void setLeadSelectionIndex(int leadIndex) { + if (selectionMode == SINGLE_SELECTION) + setSelectionInterval (leadIndex, leadIndex); + int oldLeadIndex = leadSelectionIndex; if (oldLeadIndex == -1) oldLeadIndex = leadIndex; @@ -436,7 +439,7 @@ public class DefaultListSelectionModel implements Cloneable, oldSel = sel.clone(); if (selectionMode == SINGLE_SELECTION) - sel.clear(); + setSelectionInterval(index0, index1); // COMPAT: Like Sun (but not like IBM), we allow calls to // addSelectionInterval when selectionMode is @@ -447,10 +450,7 @@ public class DefaultListSelectionModel implements Cloneable, isSelectedIndex(index1) || isSelectedIndex(Math.max(lo-1,0)) || isSelectedIndex(Math.min(hi+1,sel.size())))) - sel.clear(); - - if (selectionMode == SINGLE_SELECTION) - index0 = index1; + sel.clear(); // We have to update the anchorSelectionIndex and leadSelectionIndex // variables diff --git a/javax/swing/JList.java b/javax/swing/JList.java index a5a999c07..cfc9b6132 100644 --- a/javax/swing/JList.java +++ b/javax/swing/JList.java @@ -1384,7 +1384,7 @@ public class JList extends JComponent implements Accessible, Scrollable n++; int [] v = new int[n]; j = 0; - for (i = lo; i < hi; ++i) + for (i = lo; i <= hi; ++i) if (selectionModel.isSelectedIndex(i)) v[j++] = i; return v; |