Home » openjdk-7 » javax » swing » [javadoc | source]
javax.swing
public class: DefaultListModel [javadoc | source]
java.lang.Object
   javax.swing.AbstractListModel<E>
      javax.swing.DefaultListModel

All Implemented Interfaces:
    java$io$Serializable, ListModel

Direct Known Subclasses:
    OptionListModel, EntryModel

This class loosely implements the java.util.Vector API, in that it implements the 1.1.x version of java.util.Vector, has no collection class support, and notifies the ListDataListeners when changes occur. Presently it delegates to a Vector, in a future release it will be a real Collection implementation.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder .

Fields inherited from javax.swing.AbstractListModel:
listenerList
Method from javax.swing.DefaultListModel Summary:
add,   addElement,   capacity,   clear,   contains,   copyInto,   elementAt,   elements,   ensureCapacity,   firstElement,   get,   getElementAt,   getSize,   indexOf,   indexOf,   insertElementAt,   isEmpty,   lastElement,   lastIndexOf,   lastIndexOf,   remove,   removeAllElements,   removeElement,   removeElementAt,   removeRange,   set,   setElementAt,   setSize,   size,   toArray,   toString,   trimToSize
Methods from javax.swing.AbstractListModel:
addListDataListener,   fireContentsChanged,   fireIntervalAdded,   fireIntervalRemoved,   getListDataListeners,   getListeners,   removeListDataListener
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.swing.DefaultListModel Detail:
 public  void add(int index,
    E element) 
    Inserts the specified element at the specified position in this list.

    Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index > size()).

 public  void addElement(E element) 
    Adds the specified component to the end of this list.
 public int capacity() 
    Returns the current capacity of this list.
 public  void clear() 
    Removes all of the elements from this list. The list will be empty after this call returns (unless it throws an exception).
 public boolean contains(Object elem) 
    Tests whether the specified object is a component in this list.
 public  void copyInto(Object[] anArray) 
    Copies the components of this list into the specified array. The array must be big enough to hold all the objects in this list, else an IndexOutOfBoundsException is thrown.
 public E elementAt(int index) 
    Returns the component at the specified index. Throws an ArrayIndexOutOfBoundsException if the index is negative or not less than the size of the list.
    Note: Although this method is not deprecated, the preferred method to use is get(int), which implements the List interface defined in the 1.2 Collections framework.
 public Enumeration<E> elements() 
    Returns an enumeration of the components of this list.
 public  void ensureCapacity(int minCapacity) 
    Increases the capacity of this list, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.
 public E firstElement() 
    Returns the first component of this list. Throws a NoSuchElementException if this vector has no components.
 public E get(int index) 
    Returns the element at the specified position in this list.

    Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()).

 public E getElementAt(int index) 
    Returns the component at the specified index.
    Note: Although this method is not deprecated, the preferred method to use is get(int), which implements the List interface defined in the 1.2 Collections framework.
 public int getSize() 
    Returns the number of components in this list.

    This method is identical to size, which implements the List interface defined in the 1.2 Collections framework. This method exists in conjunction with setSize so that size is identifiable as a JavaBean property.

 public int indexOf(Object elem) 
    Searches for the first occurrence of elem.
 public int indexOf(Object elem,
    int index) 
    Searches for the first occurrence of elem, beginning the search at index.
 public  void insertElementAt(E element,
    int index) 
    Inserts the specified element as a component in this list at the specified index.

    Throws an ArrayIndexOutOfBoundsException if the index is invalid.

    Note: Although this method is not deprecated, the preferred method to use is add(int,Object), which implements the List interface defined in the 1.2 Collections framework.
 public boolean isEmpty() 
    Tests whether this list has any components.
 public E lastElement() 
    Returns the last component of the list. Throws a NoSuchElementException if this vector has no components.
 public int lastIndexOf(Object elem) 
    Returns the index of the last occurrence of elem.
 public int lastIndexOf(Object elem,
    int index) 
    Searches backwards for elem, starting from the specified index, and returns an index to it.
 public E remove(int index) 
    Removes the element at the specified position in this list. Returns the element that was removed from the list.

    Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()).

 public  void removeAllElements() 
    Removes all components from this list and sets its size to zero.
    Note: Although this method is not deprecated, the preferred method to use is clear, which implements the List interface defined in the 1.2 Collections framework.
 public boolean removeElement(Object obj) 
    Removes the first (lowest-indexed) occurrence of the argument from this list.
 public  void removeElementAt(int index) 
    Deletes the component at the specified index.

    Throws an ArrayIndexOutOfBoundsException if the index is invalid.

    Note: Although this method is not deprecated, the preferred method to use is remove(int), which implements the List interface defined in the 1.2 Collections framework.
 public  void removeRange(int fromIndex,
    int toIndex) 
    Deletes the components at the specified range of indexes. The removal is inclusive, so specifying a range of (1,5) removes the component at index 1 and the component at index 5, as well as all components in between.

    Throws an ArrayIndexOutOfBoundsException if the index was invalid. Throws an IllegalArgumentException if fromIndex > toIndex.

 public E set(int index,
    E element) 
    Replaces the element at the specified position in this list with the specified element.

    Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()).

 public  void setElementAt(E element,
    int index) 
    Sets the component at the specified index of this list to be the specified element. The previous component at that position is discarded.

    Throws an ArrayIndexOutOfBoundsException if the index is invalid.

    Note: Although this method is not deprecated, the preferred method to use is set(int,Object), which implements the List interface defined in the 1.2 Collections framework.
 public  void setSize(int newSize) 
    Sets the size of this list.
 public int size() 
    Returns the number of components in this list.
 public Object[] toArray() 
    Returns an array containing all of the elements in this list in the correct order.
 public String toString() 
    Returns a string that displays and identifies this object's properties.
 public  void trimToSize() 
    Trims the capacity of this list to be the list's current size.