| public class javax.swing DefaultListModel
|
Java SE 6 |
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.
| version | 1.36 11/17/05 |
| Constructors | |
|---|---|
| public | DefaultListModel() |
| Methods | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| public void | add(int index, Object element) Details
Inserts the specified element at the specified position in this list.
Throws an
| ||||||||
| public void | addElement(Object obj) Details
Adds the specified component to the end of this list.
| ||||||||
| public int | capacity() Details
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) Details
Tests whether the specified object is a component in this list.
| ||||||||
| public void | copyInto(Object[] anArray) Details
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 Object | elementAt(int index) Details
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
| ||||||||
| public Enumeration | elements() Details
Returns an enumeration of the components of this list.
| ||||||||
| public void | ensureCapacity(int minCapacity) Details
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 Object | firstElement() Details
Returns the first component of this list.
Throws a NoSuchElementException if this
vector has no components.
| ||||||||
| public Object | get(int index) Details
Returns the element at the specified position in this list.
Throws an
| ||||||||
| public int | indexOf(Object elem) Details
Searches for the first occurrence of elem.
| ||||||||
| public int | indexOf(Object elem, int index) Details
Searches for the first occurrence of elem, beginning
the search at index.
| ||||||||
| public void | insertElementAt(Object obj, int index) Details
Inserts the specified object as a component in this list at the
specified index.
Throws an Note: Although this method is not deprecated, the preferred method to use is
| ||||||||
| public Object | lastElement() Details
Returns the last component of the list.
Throws a NoSuchElementException if this vector
has no components.
| ||||||||
| public int | lastIndexOf(Object elem) Details
Returns the index of the last occurrence of elem.
| ||||||||
| public int | lastIndexOf(Object elem, int index) Details
Searches backwards for elem, starting from the
specified index, and returns an index to it.
| ||||||||
| public Object | remove(int index) Details
Removes the element at the specified position in this list.
Returns the element that was removed from the list.
Throws an
| ||||||||
| public void | removeAllElements() Details
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
| ||||||||
| public boolean | removeElement(Object obj) Details
Removes the first (lowest-indexed) occurrence of the argument
from this list.
| ||||||||
| public void | removeElementAt(int index) Details
Deletes the component at the specified index.
Throws an Note: Although this method is not deprecated, the preferred method to use is
| ||||||||
| public void | removeRange(int fromIndex, int toIndex) Details
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
| ||||||||
| public Object | set(int index, Object element) Details
Replaces the element at the specified position in this list with the
specified element.
Throws an
| ||||||||
| public int | size() Details
Returns the number of components in this list.
| ||||||||
| public Object[] | toArray() Details
Returns an array containing all of the elements in this list in the
correct order.
| ||||||||
| public String | toString() Details
Returns a string that displays and identifies this
object's properties.
| ||||||||
| public void | trimToSize() Details
Trims the capacity of this list to be the list's current size.
| ||||||||
| Properties | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| public void | setElementAt(Object obj, int index) Details
Sets the component at the specified index of this
list to be the specified object. The previous component at that
position is discarded.
Throws an Note: Although this method is not deprecated, the preferred method to use is
| ||||||||
| public Object | getElementAt(int index) Details
Returns the component at the specified index.
Note: Although this method is not deprecated, the preferred method to use is
| ||||||||
| public boolean | isEmpty() Details
Tests whether this list has any components.
| ||||||||
| public void | setSize(int newSize) Details
Sets the size of this list.
| ||||||||
| public int | getSize() Details
Returns the number of components in this list.
This method is identical to
| ||||||||
| About DocWeb · Bundles · Export · Export All | Top 10 · Statistics · Login |
| About Sun · Contact · Privacy · Terms of Use · Trademarks | Java SE 6 · Copyright © 1994-2009 Sun Microsystems, Inc.All rights reserved. Use is subject to license terms |
![]() |
![]() |
|