Class CachedComboBoxModel<T>

java.lang.Object
javax.swing.AbstractListModel<T>
net.emustudio.emulib.ui.components.CachedComboBoxModel<T>
Type Parameters:
T - item type
All Implemented Interfaces:
Serializable, ComboBoxModel<T>, ListModel<T>

@NotThreadSafe public class CachedComboBoxModel<T> extends AbstractListModel<T> implements ComboBoxModel<T>
Combo box model keeping the 10 most recently added items, most recent first.

The first added item becomes selected; later additions do not change the selection.

See Also:
  • Constructor Details

    • CachedComboBoxModel

      public CachedComboBoxModel()
  • Method Details

    • add

      public void add(T item)
      Adds an item to the front. An already present item is moved to the front; the oldest item is dropped when the limit is exceeded.
      Parameters:
      item - item to add
      Throws:
      NullPointerException - if the item is null
    • setSelectedItem

      public void setSelectedItem(Object item)
      Specified by:
      setSelectedItem in interface ComboBoxModel<T>
    • getSelectedItem

      public Object getSelectedItem()
      Specified by:
      getSelectedItem in interface ComboBoxModel<T>
    • getSize

      public int getSize()
      Specified by:
      getSize in interface ListModel<T>
    • getElementAt

      public T getElementAt(int index)
      Specified by:
      getElementAt in interface ListModel<T>