Class ListSelector<T>

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class ListSelector<T> extends JPanel
GUI widget that allows the user to select items from a list into a new list. Layout is two lists with buttons in between for moving items back and forth between the lists.
Author:
Nick Collier
See Also:
  • Constructor Details

    • ListSelector

      public ListSelector()
    • ListSelector

      public ListSelector(List<T> sourceList, List<T> targetList, boolean orderButtons)
      Creates list selector from the specified lists.
      Parameters:
      sourceList - contains the items to put in the source left-hand side list
      targetList - contains the items to put in the target right-hand side list.
      orderButtons - boolean for using order buttons in the target list.
    • ListSelector

      public ListSelector(String title, List<T> sourceList, List<T> targetList, boolean orderButtons)
      Creates list selector from the specified lists.
      Parameters:
      title - a title to display above the lists
      sourceList - contains the items to put in the source left-hand side list
      targetList - contains the items to put in the target right-hand side list.
      orderButtons - boolean for using order buttons in the target list.
  • Method Details

    • setLists

      public void setLists(List<T> sourceList, List<T> targetList)
    • getTargetListModel

      public DefaultListModel getTargetListModel()
    • getSourceListModel

      public DefaultListModel getSourceListModel()
    • addActionListeners

      public void addActionListeners(ActionListener listener)
    • getSelectedItems

      public List<T> getSelectedItems()
      Gets the list of items the user has selected. These items will be whatever is in the right hand target list when this method is called.
      Returns:
      the list of items the user has selected.
    • getPanel

      public JPanel getPanel()
      Gets the panel containing the widget.
      Returns:
      the panel containing the widget.
    • main

      public static void main(String[] args)