Class 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
    • Field Summary

      • Fields inherited from class javax.swing.AbstractListModel

        listenerList
    • 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
      • Methods inherited from interface javax.swing.ListModel

        addListDataListener, 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 interface LazyLoadListModel<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 interface LazyLoadListModel<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 interface LazyLoadListModel<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 interface LazyLoadListModel<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 insert
        index - 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 interface LazyLoadListModel<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 interface javax.swing.ListModel<T>
      • getSize

        public int getSize()
        Specified by:
        getSize in interface javax.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 interface LazyLoadListModel<T>
        Returns:
        true if the item is in the list
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<T>