Class CheckBoxCellRenderer<E extends CheckableItem>

java.lang.Object
com.compomics.util.gui.CheckBoxCellRenderer<E>
Type Parameters:
E - the checkable item
All Implemented Interfaces:
ListCellRenderer<E>

public class CheckBoxCellRenderer<E extends CheckableItem> extends Object implements ListCellRenderer<E>
Cell renderer for JComboBox supporting multiple selection. Based on https://java-swing-tips.blogspot.com/2016/07/select-multiple-jcheckbox-in-jcombobox.html.
Author:
Harald Barsnes
  • Constructor Details

    • CheckBoxCellRenderer

      public CheckBoxCellRenderer()
  • Method Details

    • getListCellRendererComponent

      public Component getListCellRendererComponent(JList list, CheckableItem value, int index, boolean isSelected, boolean cellHasFocus)
      Specified by:
      getListCellRendererComponent in interface ListCellRenderer<E extends CheckableItem>
    • getCheckedItems

      public ArrayList<String> getCheckedItems(ListModel model)
      Returns the checked items as an array of strings.
      Parameters:
      model - the list model
      Returns:
      the checked items as an array of strings
    • setCheckedItem

      public void setCheckedItem(ListModel model, String itemName)
      Checks the item with the given name in the list.
      Parameters:
      model - the list model
      itemName - the name of the item to check