Class DefaultListModel<T>

    • Field Detail

      • elements

        protected java.util.List<T> elements
      • editable

        protected boolean editable
    • Constructor Detail

      • DefaultListModel

        public DefaultListModel()
    • Method Detail

      • add

        public void add​(T element,
                        boolean removable,
                        boolean movable)
        Adds element to the list.
        Parameters:
        element - the element to be added
        removable - whether element should be marked as removable or not
        movable - whether element should be marked as movable or not
      • add

        public void add​(int index,
                        T element)
                 throws java.lang.IndexOutOfBoundsException
        Throws:
        java.lang.IndexOutOfBoundsException
      • add

        public void add​(int index,
                        T element,
                        boolean removable,
                        boolean movable)
                 throws java.lang.IndexOutOfBoundsException
        Throws:
        java.lang.IndexOutOfBoundsException
      • addAll

        public void addAll​(java.util.Collection<T> elements,
                           boolean removable,
                           boolean movable)
        Appends all of the elements in elements to the end of this list. Any registered ListDataListeners will be notified that an interval has been added.
        Parameters:
        elements - elements to be appended
        removable - whether the elements are removable or not
        movable - whether the elements are movable or not
      • clearAndAddAll

        public void clearAndAddAll​(java.util.Collection<? extends T> elements,
                                   boolean removable,
                                   boolean movable)
        Clears all the elements of the current list, then adds the elements of elements and finally fires a ListDataEvent.CONTENTS_CHANGED event i.e. no add and/or remove events are sent.

        Same as clearAndAddAll(elements, false, false, true).
        Parameters:
        elements - the elements to add
        removable - whether the elements are removable or not
        movable - whether the elements are movable or not
        See Also:
        clearAndAddAll(Collection)
      • clearAndAddAll

        public void clearAndAddAll​(java.util.Collection<? extends T> elements,
                                   boolean removable,
                                   boolean movable,
                                   boolean fireEvent)
        Clears all the elements of the current list, then adds the elements of elements and, if fireEvent is true, finally fires a ListDataEvent.CONTENTS_CHANGED event i.e. no add and/or remove events are sent.
        Parameters:
        elements - the elements to add
        removable - whether the elements are removable or not
        movable - whether the elements are movable or not
        fireEvent - whether an event should be fired or not
        See Also:
        clearAndAddAll(Collection)
      • set

        public void set​(int index,
                        T element)
                 throws java.lang.IndexOutOfBoundsException
        Throws:
        java.lang.IndexOutOfBoundsException
      • set

        public T set​(int index,
                     T element,
                     boolean removable,
                     boolean movable)
      • removeRange

        public void removeRange​(int fromIndex,
                                int toIndex)
                         throws java.lang.ArrayIndexOutOfBoundsException,
                                java.lang.IllegalArgumentException
        Removes elements in the range [fromIndex toIndex].
        Parameters:
        fromIndex - (inclusive) index of the first element in the range
        toIndex - (inclusive) index of the last element in the range
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - if either fromIndex or toIndex is invalid
        java.lang.IllegalArgumentException - if fromIndex is greater than toIndex
      • remove

        public T remove​(int index)
                 throws java.lang.IndexOutOfBoundsException
        Throws:
        java.lang.IndexOutOfBoundsException
      • remove

        public boolean remove​(T element)
      • removeAll

        public void removeAll​(java.util.Collection<T> elements)
      • elementAt

        public T elementAt​(int index)
                    throws java.lang.IndexOutOfBoundsException
        Description copied from interface: ListModel
        Returns the element at position index.
        Parameters:
        index - position of the element to get
        Returns:
        the element at position index
        Throws:
        java.lang.IndexOutOfBoundsException - if there is no element at position index
      • getElements

        public java.util.List<T> getElements()
        Description copied from interface: ListModel
        Returns all elements.
        Returns:
        list containing all elements
      • size

        public int size()
        Description copied from interface: ListModel
        Returns the size of this list i.e. the number of elements stored.
        Returns:
        this list's size
      • setEditable

        public void setEditable​(boolean editable)
      • isEditable

        public boolean isEditable()
        Description copied from interface: ListModel
        Returns whether this list is marked as _editable_ or not.
        Returns:
        true if this list is marked as editable, false otherwise
      • setMovable

        public void setMovable​(int index,
                               boolean movable)
      • isMovable

        public boolean isMovable​(int index)
                          throws java.lang.IndexOutOfBoundsException
        Description copied from interface: ListModel
        Returns whether the element at position index is movable or not.
        Parameters:
        index - position of the element
        Returns:
        true if the element is movable, false otherwise
        Throws:
        java.lang.IndexOutOfBoundsException - if there is no element at position index
      • setRemovable

        public void setRemovable​(int index,
                                 boolean removable)
      • isRemovable

        public boolean isRemovable​(int index)
                            throws java.lang.IndexOutOfBoundsException
        Description copied from interface: ListModel
        Returns whether the element at position index is removable or not.
        Parameters:
        index - position of the element
        Returns:
        true if the element is removable, false otherwise
        Throws:
        java.lang.IndexOutOfBoundsException - if there is no element at position index
      • setMovableElementsModel

        public void setMovableElementsModel​(ListSelectionModel model)
      • setRemovableElementsModel

        public void setRemovableElementsModel​(ListSelectionModel model)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isEmpty

        public boolean isEmpty()