-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
b31
-
x86
-
linux
FULL PRODUCT VERSION :
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_06-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux ubuntu 2.6.12-10-amd64-generic #1 Fri Apr 28 13:18:42 UTC 2006 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The setSelectionMode() specification doesn't say what happens to the existing selections when changing from a less restrictive mode to a more restrictive mode (for example, from SINGLE_INTERVAL_SELECTION to SINGLE_SELECTION).
It appears that the current implementation doesn't modify the selections at all, which leaves the model in an inconsistent state. See the example below, where a model ends up in SINGLE_SELECTION mode with two items selected.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See executable test case.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect at most 1 item to remain selected. Or perhaps the change of mode should clear all current selections.
ACTUAL -
Item 1 is selected : true
Item 2 is selected : true
1.5.0_06
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.DefaultListSelectionModel;
import javax.swing.ListSelectionModel;
public class ListSelectionModelTest {
public static void main(String[] args) {
System.out.println("Running on: " + System.getProperty("java.version"));
DefaultListSelectionModel m = new DefaultListSelectionModel();
m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
m.setSelectionInterval(1, 2);
m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
System.out.println("Item 1 is selected : " + m.isSelectedIndex(1));
System.out.println("Item 2 is selected : " + m.isSelectedIndex(2));
}
}
---------- END SOURCE ----------
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_06-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux ubuntu 2.6.12-10-amd64-generic #1 Fri Apr 28 13:18:42 UTC 2006 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The setSelectionMode() specification doesn't say what happens to the existing selections when changing from a less restrictive mode to a more restrictive mode (for example, from SINGLE_INTERVAL_SELECTION to SINGLE_SELECTION).
It appears that the current implementation doesn't modify the selections at all, which leaves the model in an inconsistent state. See the example below, where a model ends up in SINGLE_SELECTION mode with two items selected.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See executable test case.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect at most 1 item to remain selected. Or perhaps the change of mode should clear all current selections.
ACTUAL -
Item 1 is selected : true
Item 2 is selected : true
1.5.0_06
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.DefaultListSelectionModel;
import javax.swing.ListSelectionModel;
public class ListSelectionModelTest {
public static void main(String[] args) {
System.out.println("Running on: " + System.getProperty("java.version"));
DefaultListSelectionModel m = new DefaultListSelectionModel();
m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
m.setSelectionInterval(1, 2);
m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
System.out.println("Item 1 is selected : " + m.isSelectedIndex(1));
System.out.println("Item 2 is selected : " + m.isSelectedIndex(2));
}
}
---------- END SOURCE ----------
- relates to
-
JDK-8191436 ListSelectionModel.setSelectionMode() underspecified
-
- Resolved
-