|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.AbstractListModel | +--javax.swing.DefaultListModel
This class implements the java.util.Vector API 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. A future release of Swing will provide support for long term persistence.
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 if 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 occurence of the given argument. |
int |
indexOf(Object elem,
int index)
Searches for the first occurence of the given argument, 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 if this list has no components. |
Object |
lastElement()
Returns the last component of the list. |
int |
lastIndexOf(Object elem)
Returns the index of the last occurrence of the specified object in this list. |
int |
lastIndexOf(Object elem,
int index)
Searches backwards for the specified object, 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, 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.
size()
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.
index
- an index into this list.ArrayIndexOutOfBoundsException
- if the index
is negative or not less than the current size of this
list.
given.get(int)
public void copyInto(Object[] anArray)
anArray
- the array into which the components get copied.Vector.copyInto(Object[])
public void trimToSize()
Vector.trimToSize()
public void ensureCapacity(int minCapacity)
minCapacity
- the desired minimum capacity.Vector.ensureCapacity(int)
public void setSize(int newSize)
newSize
- the new size of this list.Vector.setSize(int)
public int capacity()
Vector.capacity()
public int size()
Vector.size()
public boolean isEmpty()
true
if and only if this list has
no components, that is, its size is zero;
false
otherwise.Vector.isEmpty()
public Enumeration elements()
Vector.elements()
public boolean contains(Object elem)
elem
- an object.true
if the specified object
is the same as a component in this listVector.contains(Object)
public int indexOf(Object elem)
elem
- an object.-1
if the object is not found.Vector.indexOf(Object)
public int indexOf(Object elem, int index)
index
.elem
- an object.index
- the index to start searching from.index
or later in the
list; returns -1
if the object is not found.Vector.indexOf(Object,int)
public int lastIndexOf(Object elem)
elem
- the desired component.-1
if the object is not found.Vector.lastIndexOf(Object)
public int lastIndexOf(Object elem, int index)
elem
- the desired component.index
- the index to start searching from.index
in the
list; -1
if the object is not found.Vector.lastIndexOf(Object,int)
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.
index
- an index into this list.get(int)
,
Vector.elementAt(int)
public Object firstElement()
Vector.firstElement()
public Object lastElement()
Vector.lastElement()
public void setElementAt(Object obj, int index)
index
of this
list to be the specified object. 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.
obj
- what the component is to be set to.index
- the specified index.set(int,Object)
,
Vector.setElementAt(Object,int)
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.
index
- the index of the object to remove.remove(int)
,
Vector.removeElementAt(int)
public void insertElementAt(Object obj, int index)
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.
obj
- the component to insert.index
- where to insert the new component.ArrayIndexOutOfBoundsException
- if the index was invalid.add(int,Object)
,
Vector.insertElementAt(Object,int)
public void addElement(Object obj)
obj
- the component to be added.Vector.addElement(Object)
public boolean removeElement(Object obj)
obj
- the component to be removed.true
if the argument was a component of this
list; false
otherwise.Vector.removeElement(Object)
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.
clear()
,
Vector.removeAllElements()
public String toString()
toString
in class Object
public Object[] toArray()
Throws an ArrayStoreException if the runtime type of the array a is not a supertype of the runtime type of every element in this list.
a
- the array into which the elements of the list are to
be stored, if it is big enough; otherwise, a new array of the
same runtime type is allocated for this purpose.Vector.toArray()
public Object get(int index)
Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()).
index
- index of element to return.public Object set(int index, Object element)
Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()).
index
- index of element to replace.element
- element to be stored at the specified position.public void add(int index, Object element)
Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()).
index
- index at which the specified element is to be inserted.element
- element to be inserted.public Object remove(int index)
Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()).
index
- the index of the element to removed.public void clear()
public void removeRange(int fromIndex, int toIndex)
Throws an ArrayIndexOutOfBoundsException if the index was invalid. Throws an IllegalArgumentException if fromIndex > toIndex.
fromIndex
- the index of the lower end of the rangetoIndex
- the index of the upper end of the rangeremove(int)
|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2001 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.