Class PickList<T>

Type Parameters:
T - The type of the itzems in this pick list.
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class PickList<T> extends JPanel
A pick list which provides a left and right list, where available items are picked from the left list and put into the right list.
Author:
Laurent Cohen
See Also:
  • Constructor Details

    • PickList

      public PickList()
      Default constructor.
  • Method Details

    • resetItems

      public void resetItems(List<T> allItems, List<T> pickedItems)
      Resets the lists of items managed by this UI component: all/available/picked items. The available items list is computed as the list of all items minus the items in the picked list.
      Parameters:
      allItems - the list of all items.
      pickedItems - the items that are already picked, if any.
    • getPickedItems

      public List<T> getPickedItems()
      Get the items that were picked.
      Returns:
      a list of items in the same order as in the corresponding JList.
    • getAvailableItems

      public List<T> getAvailableItems()
      Get the items that were picked.
      Returns:
      a list of items in the same order as in the corresponding JList.
    • getLeftTitle

      public String getLeftTitle()
      Get the title of the left list.
      Returns:
      the title as a string.
    • setLeftTitle

      public void setLeftTitle(String leftTitle)
      Set the title of the left list.
      Parameters:
      leftTitle - the title as a string.
    • getRightTitle

      public String getRightTitle()
      Get the title of the right list.
      Returns:
      the title as a string.
    • setRightTitle

      public void setRightTitle(String rightTitle)
      Set the title of the right list.
      Parameters:
      rightTitle - the title as a string.
    • setListCellRenderers

      public void setListCellRenderers(ListCellRenderer<T> renderer)
      Set the same cell renderer for the left and right JList components of this pick list.
      Parameters:
      renderer - the renderer for the lists on the left and on the right. If null, then no change is made.
    • setListCellRenderers

      public void setListCellRenderers(ListCellRenderer<T> leftRenderer, ListCellRenderer<T> rightRenderer)
      Set the cell renderers for the left and right JList components of this pick list.
      Parameters:
      leftRenderer - the renderer for the list on the left. If null, then no change is made tot he list on the left.
      rightRenderer - the renderer for the list on the right. If null, then no change is made tot he list on the right.
    • addPickListListener

      public void addPickListListener(PickListListener<T> listener)
      Add a listener for changes int his pick list.
      Parameters:
      listener - the listener to add.
    • removePickListListener

      public void removePickListListener(PickListListener<T> listener)
      Remove a listener for changes int his pick list.
      Parameters:
      listener - the listener to remove.
    • main

      public static void main(String[] args)
      Test the pick list.
      Parameters:
      args - not used.