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 void
addAllElements(java.util.Collection<? extends T> items)
Append items to the end of the list.void
addElement(T item)
Append an item to the list.void
addMissingElements(java.util.Collection<? extends T> elements)
Add items to the list, skipping items that are already in the list.boolean
contains(T item)
Check if an item is in the list.T
getElementAt(int index)
int
getSize()
int
indexOf(java.lang.Object item)
Get the index of an item in the list.void
insertElementAt(T item, int index)
Insert an item in the list at a specific index.java.util.Iterator<T>
iterator()
void
removeAll()
Clear the list of items.void
removeElement(java.lang.Object item)
Remove an item from the list.void
removeElementAt(int index)
Remove an item from the list.void
setElements(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:
setElements
in interfaceLazyLoadListModel<T>
- Parameters:
items
- the new items
-
addElement
public void addElement(T item)
Description copied from interface:LazyLoadListModel
Append an item to the list.- Specified by:
addElement
in interfaceLazyLoadListModel<T>
- Parameters:
item
- the item to append
-
addAllElements
public void addAllElements(java.util.Collection<? extends T> items)
Description copied from interface:LazyLoadListModel
Append items to the end of the list.- Specified by:
addAllElements
in interfaceLazyLoadListModel<T>
- Parameters:
items
- the items to append
-
addMissingElements
public void addMissingElements(java.util.Collection<? extends T> elements)
Description copied from interface:LazyLoadListModel
Add items to the list, skipping items that are already in the list.- Specified by:
addMissingElements
in 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:
indexOf
in 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:
getElementAt
in interfacejavax.swing.ListModel<T>
-
getSize
public int getSize()
- Specified by:
getSize
in interfacejavax.swing.ListModel<T>
-
contains
public boolean contains(T item)
Description copied from interface:LazyLoadListModel
Check if an item is in the list.- Specified by:
contains
in interfaceLazyLoadListModel<T>
- Returns:
- true if the item is in the list
-
-