java.lang.Object javax.swing.AbstractListModel javax.swing.DefaultListModel
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 JavaBeans TM has been added to the java.beans package. Please see XMLEncoder .
Field Summary |
---|
Fields inherited from class javax.swing. AbstractListModel |
---|
listenerList |
Constructor Summary | |
---|---|
DefaultListModel
() |
Method Summary | |
---|---|
void |
add
(int index,
Object
element) Inserts the specified element at the specified position in this list. |
void |
addElement
(
Object
obj) Adds the specified component to the end of this list. |
int |
capacity
() Returns the current capacity of this list. |
void |
clear
() Removes all of the elements from this list. |
boolean |
contains
(
Object
elem) Tests whether the specified object is a component in this list. |
void |
copyInto
(
Object
[] anArray) Copies the components of this list into the specified array. |
Object |
elementAt
(int index) Returns the component at the specified index. |
Enumeration |
elements
() Returns an enumeration of the components of this list. |
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. |
Object |
firstElement
() Returns the first component of this list. |
Object |
get
(int index) Returns the element at the specified position in this list. |
Object |
getElementAt
(int index) Returns the component at the specified index. |
int |
getSize
() Returns the number of components in this list. |
int |
indexOf
(
Object
elem) Searches for the first occurrence of elem. |
int |
indexOf
(
Object
elem, int index) Searches for the first occurrence of elem, beginning the search at index. |
void |
insertElementAt
(
Object
obj, int index) Inserts the specified object as a component in this list at the specified index. |
boolean |
isEmpty
() Tests whether this list has any components. |
Object |
lastElement
() Returns the last component of the list. |
int |
lastIndexOf
(
Object
elem) Returns the index of the last occurrence of elem. |
int |
lastIndexOf
(
Object
elem, int index) Searches backwards for elem, starting from the specified index, and returns an index to it. |
Object |
remove
(int index) Removes the element at the specified position in this list. |
void |
removeAllElements
() Removes all components from this list and sets its size to zero. |
boolean |
removeElement
(
Object
obj) Removes the first (lowest-indexed) occurrence of the argument from this list. |
void |
removeElementAt
(int index) Deletes the component at the specified index. |
void |
removeRange
(int fromIndex, int toIndex) Deletes the components at the specified range of indexes. |
Object |
set
(int index,
Object
element) Replaces the element at the specified position in this list with the specified element. |
void |
setElementAt
(
Object
obj, int index) Sets the component at the specified index of this list to be the specified object. |
void |
setSize
(int newSize) Sets the size of this list. |
int |
size
() Returns the number of components in this list. |
Object [] |
toArray
() Returns an array containing all of the elements in this list in the correct order. |
String |
toString
() Returns a string that displays and identifies this object's properties. |
void |
trimToSize
() Trims the capacity of this list to be the list's current size. |
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 , wait , wait , wait |
Constructor Detail |
---|
public DefaultListModel()
Method Detail |
---|
public int getSize()
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 Object getElementAt(int 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 void copyInto(Object[] anArray)
public void trimToSize()
public void ensureCapacity(int minCapacity)
public void setSize(int newSize)
public int capacity()
public int size()
public boolean isEmpty()
public Enumeration elements()
public boolean contains(Object elem)
public int indexOf(Object elem)
public int indexOf(Object elem, int index)
public int lastIndexOf(Object elem)
public int lastIndexOf(Object elem, int index)
public Object elementAt(int 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 Object firstElement()
public Object lastElement()
public void setElementAt(Object obj, int index)
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 removeElementAt(int 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 insertElementAt(Object obj, int 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 void addElement(Object obj)
public boolean removeElement(Object obj)
public void removeAllElements()
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 String toString()
public Object[] toArray()
public Object get(int index)
Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()).
public Object set(int index, Object element)
Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()).
public void add(int index, Object element)
Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index > size()).
public Object remove(int index)
Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()).
public void clear()
public void removeRange(int fromIndex, int toIndex)
Throws an ArrayIndexOutOfBoundsException if the index was invalid. Throws an IllegalArgumentException if fromIndex > toIndex.