public class FastListModel<E> extends AbstractListModel<E>
listenerList| Constructor and Description |
|---|
FastListModel() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(E element) |
void |
add(int index,
E element)
Inserts the specified element at the specified position in this list.
|
void |
addAll(Collection<E> elements) |
void |
addElement(E element)
Adds the specified component to the end 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.
|
E |
elementAt(int index)
Returns the component at the specified index.
|
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.
|
E |
get(int index)
Returns the element at the specified position in this list.
|
E |
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. |
void |
insertElementAt(E element,
int index)
Inserts the specified element as a component in this list at the
specified
index. |
boolean |
isEmpty()
Tests whether this list has any components.
|
E |
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.
|
E |
set(int index,
E element)
Replaces the element at the specified position in this list with the
specified element.
|
void |
setElementAt(E element,
int index)
Sets the component at the specified
index of this
list to be the specified element. |
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.
|
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListenerpublic 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 E getElementAt(int index)
Note: Although this method is not deprecated, the preferred method to use isget(int), which implements theListinterface defined in the 1.2 Collections framework.
index - an index into this listArrayIndexOutOfBoundsException - if the index
is negative or greater than the current size of this
listget(int)public void trimToSize()
Vector.trimToSize()public void ensureCapacity(int minCapacity)
minCapacity - the desired minimum capacityVector.ensureCapacity(int)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 otherwiseVector.isEmpty()public boolean contains(Object elem)
elem - an objecttrue if the specified object
is the same as a component in this listVector.contains(Object)public int indexOf(Object elem)
elem.elem - an object-1 if the object is not foundVector.indexOf(Object)public E elementAt(int index)
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 theListinterface defined in the 1.2 Collections framework.
index - an index into this listget(int),
Vector.elementAt(int)public void setElementAt(E element, int index)
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 isset(int,Object), which implements theListinterface defined in the 1.2 Collections framework.
element - what the component is to be set toindex - the specified indexset(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 isremove(int), which implements theListinterface defined in the 1.2 Collections framework.
index - the index of the object to removeremove(int),
Vector.removeElementAt(int)public void insertElementAt(E element, int index)
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 theListinterface defined in the 1.2 Collections framework.
element - the component to insertindex - where to insert the new componentArrayIndexOutOfBoundsException - if the index was invalidadd(int,Object),
Vector.insertElementAt(Object,int)public void addElement(E element)
element - the component to be addedVector.addElement(Object)public void addAll(Collection<E> elements)
public boolean removeElement(Object obj)
obj - the component to be removedtrue if the argument was a component of this
list; false otherwiseVector.removeElement(Object)public void removeAllElements()
Note: Although this method is not deprecated, the preferred method to use isclear, which implements theListinterface defined in the 1.2 Collections framework.
clear(),
Vector.removeAllElements()public String toString()
public Object[] toArray()
Vector.toArray()public E get(int index)
Throws an ArrayIndexOutOfBoundsException
if the index is out of range
(index < 0 || index >= size()).
index - index of element to returnpublic E set(int index, E element)
Throws an ArrayIndexOutOfBoundsException
if the index is out of range
(index < 0 || index >= size()).
index - index of element to replaceelement - element to be stored at the specified positionpublic void add(int index,
E 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 insertedelement - element to be insertedpublic void add(E element)
public E remove(int index)
Throws an ArrayIndexOutOfBoundsException
if the index is out of range
(index < 0 || index >= size()).
index - the index of the element to removedpublic 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)Copyright © 2021 vpc open source initiative. All rights reserved.