Package io.github.jonestimd.swing.list
Class BeanListModel<T>
- java.lang.Object
-
- javax.swing.AbstractListModel<T>
-
- io.github.jonestimd.swing.list.BeanListModel<T>
-
- Type Parameters:
T- the class of the list items
- All Implemented Interfaces:
LazyLoadListModel<T>,java.io.Serializable,java.lang.Iterable<T>,javax.swing.ListModel<T>
- Direct Known Subclasses:
BeanListComboBoxModel
public class BeanListModel<T> extends javax.swing.AbstractListModel<T> implements LazyLoadListModel<T>
A list model that contains beans.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BeanListModel()BeanListModel(java.util.Collection<? extends T> elements)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAllElements(java.util.Collection<? extends T> items)Append items to the end of the list.voidaddElement(T item)Append an item to the list.voidaddMissingElements(java.util.Collection<? extends T> elements)Add items to the list, skipping items that are already in the list.booleancontains(T item)Check if an item is in the list.TgetElementAt(int index)intgetSize()intindexOf(java.lang.Object item)Get the index of an item in the list.voidinsertElementAt(T item, int index)Insert an item in the list at a specific index.java.util.Iterator<T>iterator()voidremoveAll()Clear the list of items.voidremoveElement(java.lang.Object item)Remove an item from the list.voidremoveElementAt(int index)Remove an item from the list.voidsetElements(java.util.Collection<? extends T> items)Replace the items in the list.-
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
-
-
-
-
Constructor Detail
-
BeanListModel
public BeanListModel()
-
BeanListModel
public BeanListModel(java.util.Collection<? extends T> elements)
-
-
Method Detail
-
setElements
public void setElements(java.util.Collection<? extends T> items)
Replace the items in the list.- Specified by:
setElementsin interfaceLazyLoadListModel<T>- Parameters:
items- the new items
-
addElement
public void addElement(T item)
Description copied from interface:LazyLoadListModelAppend an item to the list.- Specified by:
addElementin interfaceLazyLoadListModel<T>- Parameters:
item- the item to append
-
addAllElements
public void addAllElements(java.util.Collection<? extends T> items)
Description copied from interface:LazyLoadListModelAppend items to the end of the list.- Specified by:
addAllElementsin interfaceLazyLoadListModel<T>- Parameters:
items- the items to append
-
addMissingElements
public void addMissingElements(java.util.Collection<? extends T> elements)
Description copied from interface:LazyLoadListModelAdd items to the list, skipping items that are already in the list.- Specified by:
addMissingElementsin interfaceLazyLoadListModel<T>- Parameters:
elements- the items to add
-
insertElementAt
public void insertElementAt(T item, int index)
Insert an item in the list at a specific index.- Parameters:
item- the item to insertindex- the index at which to add the item
-
indexOf
public int indexOf(java.lang.Object item)
Get the index of an item in the list.- Specified by:
indexOfin interfaceLazyLoadListModel<T>- Returns:
- the index of the item or -1 if it is not in the list
-
removeAll
public void removeAll()
Clear the list of items.
-
removeElement
public void removeElement(java.lang.Object item)
Remove an item from the list.- Parameters:
item- the item to remove
-
removeElementAt
public void removeElementAt(int index)
Remove an item from the list.- Parameters:
index- the index of the it
-
getElementAt
public T getElementAt(int index)
- Specified by:
getElementAtin interfacejavax.swing.ListModel<T>
-
getSize
public int getSize()
- Specified by:
getSizein interfacejavax.swing.ListModel<T>
-
contains
public boolean contains(T item)
Description copied from interface:LazyLoadListModelCheck if an item is in the list.- Specified by:
containsin interfaceLazyLoadListModel<T>- Returns:
- true if the item is in the list
-
-