Hi, I have a program here that seems to expect JList.setSelectedIndex(-1) to clear the current selection. Currently we get into trouble since we unconditionally call setSelectionInterval(-1, -1) in that case. Changing it to call clearSelection() when negative seems to make sense since it is consistent with getSelectedIndex() which returns -1 when there is no selection.
2006-01-09 Mark Wielaard <[EMAIL PROTECTED]>
* javax/swing/JList.java (setSelectedIndex): Clear selection when
argument is negative.
Does this patch make sense?
Cheers,
Mark
Index: javax/swing/JList.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JList.java,v
retrieving revision 1.44
diff -u -r1.44 JList.java
--- javax/swing/JList.java 3 Jan 2006 18:42:22 -0000 1.44
+++ javax/swing/JList.java 9 Jan 2006 15:43:27 -0000
@@ -1257,14 +1257,17 @@
*
* @param a A number in the half-open range <code>[0, x)</code> where
* <code>x = getModel.getSize()</code>, indicating the index of an
- * element in the list to select.
+ * element in the list to select. When < 0 the selection is cleared.
*
* @see #setSelectionMode
* @see #selectionModel
*/
public void setSelectedIndex(int a)
{
- selectionModel.setSelectionInterval(a, a);
+ if (a < 0)
+ selectionModel.clearSelection();
+ else
+ selectionModel.setSelectionInterval(a, a);
}
/**
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Classpath-patches mailing list [email protected] http://lists.gnu.org/mailman/listinfo/classpath-patches
