Class ListPanel<T>

Type Parameters:
T - The type for the items in this list
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class ListPanel<T> extends JPanel
This class provides a panel that contains a JList component.
See Also:
  • Constructor Details Link icon

    • ListPanel Link icon

      public ListPanel()
      Constructs a new ListPanel.
  • Method Details Link icon

    • setSelectionMode Link icon

      public void setSelectionMode(int selectionMode)
      Sets the selection mode for the list. See JList for allowed Selection modes
      Parameters:
      selectionMode - the selectionMode to use.
    • setListTitle Link icon

      public void setListTitle(String listTitle)
      Places a title just above the scrolling list.
      Parameters:
      listTitle - the title to use.
    • addListSelectionListener Link icon

      public void addListSelectionListener(ListSelectionListener listener)
      Parameters:
      listener - the listener to add
    • removeListSelectionListener Link icon

      public void removeListSelectionListener(ListSelectionListener listener)
      Parameters:
      listener - the listener to remove
    • isSelectionEmpty Link icon

      public boolean isSelectionEmpty()
      Returns true if no list items are selected.
      Returns:
      true if no list items are selected.
    • getSelectedValue Link icon

      public T getSelectedValue()
      Returns the first selected value in the list or null if nothing is selected.
      Returns:
      the first selected value in the list or null if nothing is selected.
    • getSelectedIndex Link icon

      public int getSelectedIndex()
      Get the index of the selected item in the list.
      Returns:
      the index of the selected item in the list.
    • setSelectedIndex Link icon

      public void setSelectedIndex(int i)
      Select the item at the given index.
      Parameters:
      i - the index at which to get the item.
    • setSelectedValue Link icon

      public void setSelectedValue(T item)
      Selects the item.
      Parameters:
      item - the item to select
    • getSelectedValues Link icon

      public List<T> getSelectedValues()
      Returns an array of all the selected items.
      Returns:
      an array of all the selected items.
    • refreshList Link icon

      public void refreshList(T[] dataList)
      replaces the list contents with the new list.
      Parameters:
      dataList - the new list for the contents.
    • setListData Link icon

      public void setListData(T[] data)
      Sets the list data
      Parameters:
      data - the data
    • setListModel Link icon

      public void setListModel(ListModel<T> listModel)
      Sets a list model for the internal list to use.
      Parameters:
      listModel - the list model to use.
    • getListModel Link icon

      public ListModel<T> getListModel()
      Get the list model for the list.
      Returns:
      the list model for the list.
    • getList Link icon

      public JList<T> getList()
      Return the JList component.
      Returns:
      the JList component.
    • setCellRenderer Link icon

      public void setCellRenderer(ListCellRenderer<T> r)
      Get the cell renderer for the list.
      Parameters:
      r - the cell renderer to use.
    • setListSelectionListener Link icon

      public void setListSelectionListener(ListSelectionListener listener)
      Sets the listener to be notified when the selection changes.
      Parameters:
      listener - the Listener to be notified. If listener can be null, which means no one is to be notified.
    • setDoubleClickActionListener Link icon

      public final void setDoubleClickActionListener(ActionListener listener)
      Sets the listener to be notified whenever a list item is doubleClicked.
      Parameters:
      listener - the Listener to be notified. If listener can be null, which means no one is to be notified.
    • setMouseListener Link icon

      public void setMouseListener(MouseListener l)
      Set the mouse listener for the list.
      Parameters:
      l - the mouse listener to set.
    • setKeyListener Link icon

      public void setKeyListener(KeyListener l)
    • issueWarning Link icon

      public void issueWarning()
      Displays a standard warning message about no selected objects in the list.
    • issueWarning Link icon

      public void issueWarning(String msg, String title)
      Displays any warning message.
      Parameters:
      msg - the warning message to display.
      title - the title of the dialog to display.
    • ensureIndexIsVisible Link icon

      public void ensureIndexIsVisible(int index)
      Scroll viewport such that the index is visible.
      Parameters:
      index - the index of the item in the list to make visible.
    • main Link icon

      public static void main(String[] args)
      Simple test for ListPanel class.
      Parameters:
      args - test args not used