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:
-
Field Summary
Fields inherited from class AbstractListModel
listenerList -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an item to the front.getElementAt(int index) intgetSize()voidsetSelectedItem(Object item) Methods inherited from class AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListenerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ListModel
addListDataListener, removeListDataListener
-
Constructor Details
-
CachedComboBoxModel
public CachedComboBoxModel()
-
-
Method Details
-
add
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
- Specified by:
setSelectedItemin interfaceComboBoxModel<T>
-
getSelectedItem
- Specified by:
getSelectedItemin interfaceComboBoxModel<T>
-
getSize
-
getElementAt
- Specified by:
getElementAtin interfaceListModel<T>
-