-
Enhancement
-
Resolution: Unresolved
-
P5
-
None
-
6
-
Cause Known
-
generic
-
generic
ListSelectionEvent should mention more clearly that it tracks all the changes in selection - selections AND unselections of the elements. Perfectly, there must be some examples included.
Consider the following code:
final JList jList = new JList(new Integer[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} );
jList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
jList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
System.out.println("Selected: " + Arrays.toString(jList.getSelectedIndices()));
System.out.println("first = " + e.getFirstIndex() + ", last = " + e.getLastIndex());
}
});
jList.setSelectionInterval(7, 9);
jList.addSelectionInterval(2, 3);
The output is:
Selected: [7, 8, 9]
first = 7, last = 9
Selected: [2, 3]
first = 2, last = 9
One may expect the last line to be "first = 2, last = 3".
Consider the following code:
final JList jList = new JList(new Integer[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} );
jList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
jList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
System.out.println("Selected: " + Arrays.toString(jList.getSelectedIndices()));
System.out.println("first = " + e.getFirstIndex() + ", last = " + e.getLastIndex());
}
});
jList.setSelectionInterval(7, 9);
jList.addSelectionInterval(2, 3);
The output is:
Selected: [7, 8, 9]
first = 7, last = 9
Selected: [2, 3]
first = 2, last = 9
One may expect the last line to be "first = 2, last = 3".
- duplicates
-
JDK-6464083 ListSelectionListener is notified when there was no change to the current selection
-
- Closed
-