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 ListDataListener
s 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 XMLEncoder
.
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Inserts the specified element at the specified position in this list.
| |||||||||||
Adds the specified component to the end of this list.
| |||||||||||
Returns the current capacity of this list.
| |||||||||||
Removes all of the elements from this list.
| |||||||||||
Tests whether the specified object is a component in this list.
| |||||||||||
Copies the components of this list into the specified array.
| |||||||||||
Returns the component at the specified index.
| |||||||||||
Returns an enumeration of the components of this list.
| |||||||||||
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.
| |||||||||||
Returns the first component of this list.
| |||||||||||
Returns the element at the specified position in this list.
| |||||||||||
Returns the component at the specified index.
| |||||||||||
Returns the number of components in this list.
| |||||||||||
Searches for the first occurrence of
elem , beginning
the search at index . | |||||||||||
Searches for the first occurrence of
elem . | |||||||||||
Inserts the specified object as a component in this list at the
specified
index . | |||||||||||
Tests whether this list has any components.
| |||||||||||
Returns the last component of the list.
| |||||||||||
Searches backwards for
elem , starting from the
specified index, and returns an index to it. | |||||||||||
Returns the index of the last occurrence of
elem . | |||||||||||
Removes the element at the specified position in this list.
| |||||||||||
Removes all components from this list and sets its size to zero.
| |||||||||||
Removes the first (lowest-indexed) occurrence of the argument
from this list.
| |||||||||||
Deletes the component at the specified index.
| |||||||||||
Deletes the components at the specified range of indexes.
| |||||||||||
Replaces the element at the specified position in this list with the
specified element.
| |||||||||||
Sets the component at the specified
index of this
list to be the specified object. | |||||||||||
Sets the size of this list.
| |||||||||||
Returns the number of components in this list.
| |||||||||||
Returns an array containing all of the elements in this list in the
correct order.
| |||||||||||
Returns a string that displays and identifies this
object's properties.
| |||||||||||
Trims the capacity of this list to be the list's current size.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() |
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()
).
index | index at which the specified element is to be inserted |
---|---|
element | element to be inserted |
Adds the specified component to the end of this list.
obj | the component to be added |
---|
Removes all of the elements from this list. The list will be empty after this call returns (unless it throws an exception).
Tests whether the specified object is a component in this list.
elem | an object |
---|
true
if the specified object
is the same as a component in this listCopies 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.
anArray | the array into which the components get copied |
---|
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 isget(int)
, which implements theList
interface defined in the 1.2 Collections framework.
index | an index into this list |
---|
Returns an enumeration of the components of this list.
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.
minCapacity | the desired minimum capacity |
---|
Returns the first component of this list.
Throws a NoSuchElementException
if this
vector has no components.
Returns the element at the specified position in this list.
Throws an ArrayIndexOutOfBoundsException
if the index is out of range
(index < 0 || index >= size()
).
index | index of element to return |
---|
Returns the component at the specified index.
Note: Although this method is not deprecated, the preferred method to use isget(int)
, which implements theList
interface defined in the 1.2 Collections framework.
index | an index into this list |
---|
ArrayIndexOutOfBoundsException | if the index
is negative or greater than the current size of this
list |
---|
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.
Searches for the first occurrence of elem
, beginning
the search at index
.
elem | an desired component |
---|---|
index | the index from which to begin searching |
elem
is found after index
; returns -1
if the elem
is not found in the listSearches for the first occurrence of elem
.
elem | an object |
---|
-1
if the object is not foundInserts the specified object 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 isadd(int,Object)
, which implements theList
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 |
---|
Tests whether this list has any components.
true
if and only if this list has
no components, that is, its size is zero;
false
otherwiseReturns the last component of the list.
Throws a NoSuchElementException
if this vector
has no components.
Searches backwards for elem
, starting from the
specified index, and returns an index to it.
elem | the desired component |
---|---|
index | the index to start searching from |
elem
in this list at position less than index
;
returns -1
if the object is not foundReturns the index of the last occurrence of elem
.
elem | the desired component |
---|
elem
in the list; returns -1
if the object is not foundRemoves 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()
).
index | the index of the element to removed |
---|
Removes all components from this list and sets its size to zero.
Note: Although this method is not deprecated, the preferred method to use isclear
, which implements theList
interface defined in the 1.2 Collections framework.
Removes the first (lowest-indexed) occurrence of the argument from this list.
obj | the component to be removed |
---|
true
if the argument was a component of this
list; false
otherwiseDeletes 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 isremove(int)
, which implements theList
interface defined in the 1.2 Collections framework.
index | the index of the object to remove |
---|
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
.
fromIndex | the index of the lower end of the range |
---|---|
toIndex | the index of the upper end of the range |
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()
).
index | index of element to replace |
---|---|
element | element to be stored at the specified position |
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 ArrayIndexOutOfBoundsException
if the index
is invalid.
Note: Although this method is not deprecated, the preferred method to use isset(int,Object)
, which implements theList
interface defined in the 1.2 Collections framework.
obj | what the component is to be set to |
---|---|
index | the specified index |
Returns the number of components in this list.
Returns an array containing all of the elements in this list in the correct order.
Returns a string that displays and identifies this object's properties.
Trims the capacity of this list to be the list's current size.