com.alee.extended.list
Class CheckBoxListModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by com.alee.laf.list.WebListModel<CheckBoxCellData>
          extended by com.alee.extended.list.CheckBoxListModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.ListModel

public class CheckBoxListModel
extends WebListModel<CheckBoxCellData>

Custom list model for checkbox list component. This class overrides a few default model methods to avoid casting to checkbox cell data object. There are also methods to add new elements and change/retrieve checkbox selection state.

Author:
Mikle Garin
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.alee.laf.list.WebListModel
delegate
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
CheckBoxListModel()
          Constructs checkbox list model.
 
Method Summary
 void addCheckBoxElement(java.lang.Object userObject)
          Adds new checkbox cell data with a specified user object into list model.
 void addCheckBoxElement(java.lang.Object userObject, boolean selected)
          Adds new checkbox cell data with a specified user object and checkbox selection state into list model.
 void addCheckBoxElementAt(int index, java.lang.Object userObject)
          Adds new checkbox cell data with a specified user object into list model at the specified index.
 void addCheckBoxElementAt(int index, java.lang.Object userObject, boolean selected)
          Adds new checkbox cell data with a specified user object and checkbox selection state into list model at the specified index.
 java.util.List<java.lang.Object> getCheckedValues()
          Returns list of values from checked cells.
 void invertCheckBoxSelection(int index)
          Inverts checkbox selection at the specified cell index.
 boolean isCheckBoxSelected(int index)
          Returns whether checkbox under the specified cell index is selected or not.
 boolean setCheckBoxSelected(int index, boolean selected)
          Sets whether checkbox at the specified cell index is selected or not and returns whether selection has changed or not.
 
Methods inherited from class com.alee.laf.list.WebListModel
add, add, addElement, addElements, addElements, capacity, clear, contains, copyInto, elementAt, elements, ensureCapacity, firstElement, get, getElementAt, getElements, getSize, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAllAfter, removeAllBefore, removeAllElements, removeElement, removeElementAt, removeElements, removeElements, removeRange, set, setElementAt, setElements, setSize, size, toArray, toString, trimToSize, update
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CheckBoxListModel

public CheckBoxListModel()
Constructs checkbox list model.

Method Detail

addCheckBoxElement

public void addCheckBoxElement(java.lang.Object userObject)
Adds new checkbox cell data with a specified user object into list model.

Parameters:
userObject - user object

addCheckBoxElement

public void addCheckBoxElement(java.lang.Object userObject,
                               boolean selected)
Adds new checkbox cell data with a specified user object and checkbox selection state into list model.

Parameters:
userObject - user object
selected - whether checkbox selected or not

addCheckBoxElementAt

public void addCheckBoxElementAt(int index,
                                 java.lang.Object userObject)
Adds new checkbox cell data with a specified user object into list model at the specified index.

Parameters:
index - new cell index
userObject - user object

addCheckBoxElementAt

public void addCheckBoxElementAt(int index,
                                 java.lang.Object userObject,
                                 boolean selected)
Adds new checkbox cell data with a specified user object and checkbox selection state into list model at the specified index.

Parameters:
index - new cell index
userObject - user object
selected - whether checkbox selected or not

isCheckBoxSelected

public boolean isCheckBoxSelected(int index)
Returns whether checkbox under the specified cell index is selected or not.

Parameters:
index - cell index
Returns:
true if checkbox at the specified cell index is selected, false otherwise

getCheckedValues

public java.util.List<java.lang.Object> getCheckedValues()
Returns list of values from checked cells.

Returns:
list of values from checked cells

invertCheckBoxSelection

public void invertCheckBoxSelection(int index)
Inverts checkbox selection at the specified cell index.

Parameters:
index - cell index

setCheckBoxSelected

public boolean setCheckBoxSelected(int index,
                                   boolean selected)
Sets whether checkbox at the specified cell index is selected or not and returns whether selection has changed or not.

Parameters:
index - cell index
selected - whether checkbox is selected or not
Returns:
true if selection has changed, false otherwise