Class BasicCheckBoxList<T>

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable
Direct Known Subclasses:
ColumnCheckBoxList

public class BasicCheckBoxList<T> extends CheckBoxList<T>
Basic implementation of CheckBoxList. This provides a simple internal implementation of the checkbox model and uses a DefaultListModel for the data. Various parts can be overridden as required.
Since:
21 Dec 2017
Author:
Mark Taylor
See Also:
  • Constructor Details

    • BasicCheckBoxList

      public BasicCheckBoxList(boolean canSelect)
      Constructs a list with default rendering.
      Parameters:
      canSelect - true if list item selection is permitted
    • BasicCheckBoxList

      public BasicCheckBoxList(boolean canSelect, CheckBoxList.Rendering<T,?> rendering)
      Constructs a list with custom rendering.
      Parameters:
      canSelect - true if list item selection is permitted
      rendering - how to render list entries
  • Method Details

    • getModel

      public DefaultListModel<T> getModel()
      Overrides:
      getModel in class JList<T>
    • setModel

      public void setModel(ListModel<T> model)
      Overrides:
      setModel in class JList<T>
    • getItems

      public List<T> getItems()
      Returns a list of all the items currently in this list.
      Returns:
      list of all items
    • getCheckedItems

      public List<T> getCheckedItems()
      Returns a list of the items currently in this list whose check box is selected.
      Returns:
      list of active items
    • isChecked

      public boolean isChecked(T item)
      Description copied from class: CheckBoxList
      Indicates whether the checkbox for a given item is selected.
      Specified by:
      isChecked in class CheckBoxList<T>
      Parameters:
      item - list entry
      Returns:
      true iff item is selected
    • setChecked

      public void setChecked(T item, boolean isChecked)
      Description copied from class: CheckBoxList
      Sets whether the checkbox for a given item is selected. Called when the user interacts with the checkbox. It is up to the concrete implementation to ensure that this is reflected by the isChecked method.
      Specified by:
      setChecked in class CheckBoxList<T>
      Parameters:
      item - list entry
      isChecked - whether item should be selected
    • moveItem

      public void moveItem(int ifrom, int ito)
      Description copied from class: CheckBoxList
      Indicates that the user has requested a reordering of the list model. It is up to the concrete implementation to ensure that this is reflected in the list model.
      Specified by:
      moveItem in class CheckBoxList<T>
      Parameters:
      ifrom - source list index
      ito - destination list index