Class EditableList

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
EditableFileList

public class EditableList extends JComponent implements Accessible
A component that displays an editable list of items.
See Also:
  • Field Details

    • uif

      protected final UIFactory uif
      The factory used to create the GUI elements of the component.
    • listModel

      protected DefaultListModel<Object> listModel
      The list model that contains the elements of the list.
  • Constructor Details

    • EditableList

      public EditableList()
      Create an empty component, using a standard UIFactory for this class, and using resources beginning with "list.".
    • EditableList

      public EditableList(UIFactory uif, String uiKey)
      Create an empty component, using a specified UIFactory and resource prefix.
      Parameters:
      uif - The UIFactory used to construct the component
      uiKey - The prefix for any UI resources that may be required
  • Method Details

    • getAccessibleContext

      public AccessibleContext getAccessibleContext()
      Get the accessible context for this pane.
      Specified by:
      getAccessibleContext in interface Accessible
      Overrides:
      getAccessibleContext in class Component
      Returns:
      the accessible context for this pane
    • setEnabled

      public void setEnabled(boolean b)
      Set whether or not the list can be edited by the user.
      Overrides:
      setEnabled in class JComponent
      Parameters:
      b - if true, the component can be edited by the user; if false, it cannot
    • clear

      public void clear()
      Remove all entries from the list.
    • getItems

      public Object[] getItems()
      Get the items currently in the list.
      Returns:
      an array containing the items currently in the list
      See Also:
    • setItems

      public void setItems(Object... items)
      Set the items in the list. Any previous items are removed first.
      Parameters:
      items - the array of items to be put in the list.
      See Also:
    • getItems

      public Object[] getItems(Class<?> c)
      Get the items currently in the list, in an array of a specific type.
      Parameters:
      c - the component type of the array to be returned
      Returns:
      an array containing the items currently in the list
      See Also:
    • getToolTipText

      public String getToolTipText()
      Get the tool tip text that appears on the list. (Separate tool tip text will appear on the buttons to manipulate the list.)
      Overrides:
      getToolTipText in class JComponent
      Returns:
      the tool tip text that appears on the list
      See Also:
    • setToolTipText

      public void setToolTipText(String tip)
      Set the tool tip text that appears on the list. (Separate tool tip text will appear on the buttons to manipulate the list.)
      Overrides:
      setToolTipText in class JComponent
      Parameters:
      tip - the tool tip text to appear on the list
      See Also:
    • addListDataListener

      public void addListDataListener(ListDataListener l)
      Add a listener to be notified of events when the list data changes.
      Parameters:
      l - the listener to be notified
      See Also:
    • removeListDataListener

      public void removeListDataListener(ListDataListener l)
      Remove a listener that was previously added to be notified of events when the list data changes.
      Parameters:
      l - the listener to be notified
      See Also:
    • isDuplicatesAllowed

      public boolean isDuplicatesAllowed()
      Check whether or not duplicates should be allowed in the list.
      Returns:
      true if duplicates should be allowed, and false otherwise
      See Also:
    • setDuplicatesAllowed

      public void setDuplicatesAllowed(boolean b)
      Specify whether or not duplicates should be allowed in the list.
      Parameters:
      b - true if duplicates should be allowed, and false otherwise
      See Also:
    • getDisplayValue

      protected Object getDisplayValue(Object item)
      Get the display value for an item in the list. By default, the display value is the item itself.
      Parameters:
      item - the object for which to get the display value
      Returns:
      the display value for the specified item
    • getNewItem

      protected Object getNewItem()
      Invoked to get a new item to put in the list, when the user clicks the "Add" button". The default is to show an input dialog to allow the user to type in a new string. Subtypes may override this method to provide other ways of specifying items to be added, such as a file chooser.
      Returns:
      an object to be added to the list, or null if no object to be added.
    • getNewItem

      protected Object getNewItem(Object oldItem)
      Invoked to get a new item to replace an existing item in the list. The default is to show an input dialog to allow the user to type in a new string. Subtypes may override this method to provide other ways of specifying items to be added, such as a file chooser.
      Parameters:
      oldItem - the item to be replaced in the list
      Returns:
      an object to replace the old item the list, or null if no replacement should occur.