CheckBoxListWithSelectable
is a special JList which uses JCheckBox as the list element. In addition to regular JList feature, it also allows you select any number of elements in the list by selecting the check boxes.
The element is ListModel should be an instance of {@link Selectable}. If you have your own class that represents the element in the list, you can implement
Selectable
and implements a few very simple methods. If your elements are already in an array or Vector that you pass in to the constructor of JList, we will convert them to {@link DefaultSelectable} which implements
Selectable
interface.
To select an element, user can mouse click on the check box, or highlight the rows and press SPACE key to toggle the selections.
To listen to the check box selection change, you can call addItemListener to add an ItemListener.
Please note, there are two implementations of CheckBoxList. CheckBoxListWithSelectable is one. There is also another one call CheckBoxList. CheckBoxListWithSelectable is actually the old implementation. In 1.9.2, we introduced a new implementation and renamed the old implementation to CheckBoxListWithSelectable. The main difference between the two implementation is at how the selection state is kept. In new implementation, the selection state is kept at a separate ListSelectionModel which you can get using {@link CheckBoxList#getCheckBoxListSelectionModel()}. The old implementation kept the selection state at Selectable object in the ListModel.