Class SortableListModel<T>

  • Type Parameters:
    T - type of the elements in this list model
    All Implemented Interfaces:
    Serializable, ListModel<T>

    public class SortableListModel<T>
    extends AbstractListModel<T>
    Note: this implementation does not call automatically fireContentsChanged, its up to the caller of the different methods of this implementation to call it explicitly. This is done because in general there is a series of calls to the add/remove methods and a single call to notify that things have changed is enough.
    See Also:
    Serialized Form
    • Constructor Detail

      • SortableListModel

        public SortableListModel()
    • Method Detail

      • getSize

        public int getSize()
      • setComparator

        public void setComparator​(Comparator<T> comp)
        Sets the comparator to be used to sort the list.
        Parameters:
        comp - the comparator.
      • getElementAt

        public T getElementAt​(int i)
      • add

        public void add​(T value)
        Adds a value to the list model.
        Parameters:
        value - the value to be added.
      • remove

        public boolean remove​(T value)
        Removes a value from the list model.
        Parameters:
        value - the value to be removed.
        Returns:
        true if the element was on the list and false otherwise.
      • clear

        public void clear()
        Clears the list model.
      • addAll

        public void addAll​(Collection<T> newData)
        Adds all the elements in the collection to the list model.
        Parameters:
        newData - the collection containing the elements to be added.
      • getData

        public SortedSet<T> getData()
        Returns the data in this list model ordered.
        Returns:
        the data in this list model ordered.