Class BasicCheckBoxList<T>

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

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)
      Constructor.
      Parameters:
      canSelect - true if list item selection is permitted
  • 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
    • configureEntryRenderer

      protected void configureEntryRenderer(JComponent entryRenderer, T item, int index)
      Description copied from class: CheckBoxList
      This method is called whenever the list cell needs to be painted.
      Specified by:
      configureEntryRenderer in class CheckBoxList<T>
      Parameters:
      entryRenderer - renderer object supplied at construction time
      item - list entry
      index - index in list at which entry appears
    • toString

      protected String toString(T item)
      Maps list items to string values that can be displayed in the list. This method is just called by configureEntryRenderer(javax.swing.JComponent, T, int).
      Parameters:
      item - list entry
      Returns:
      strinification of item for user display