|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList
com.jgoodies.binding.list.ArrayListModel
public final class ArrayListModel
Adds ListModel
capabilities to its superclass
ArrayList
, i. e. allows to observe changes in the content and
structure. Useful for lists that are bound to list views, for example
JList, JComboBox and JTable.
LinkedListModel
,
Serialized FormField Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
ArrayListModel()
Constructs an empty list with an initial capacity of ten. |
|
ArrayListModel(Collection c)
Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator. |
|
ArrayListModel(int initialCapacity)
Constructs an empty list with the specified initial capacity. |
Method Summary | |
---|---|
void |
add(int index,
Object element)
Inserts the specified element at the specified position in this list. |
boolean |
add(Object o)
Appends the specified element to the end of this list. |
boolean |
addAll(Collection c)
Appends all of the elements in the specified Collection to the end of this list, in the order that they are returned by the specified Collection's Iterator. |
boolean |
addAll(int index,
Collection c)
Inserts all of the elements in the specified Collection into this list, starting at the specified position. |
void |
addListDataListener(ListDataListener l)
Adds a listener to the list that's notified each time a change to the data model occurs. |
void |
clear()
Removes all of the elements from this list. |
void |
fireContentsChanged(int index)
Notifies all registered ListDataListeners that the element
at the specified index has changed. |
Object |
getElementAt(int index)
Returns the value at the specified index. |
ListDataListener[] |
getListDataListeners()
Returns an array of all the list data listeners registered on this ArrayListModel . |
int |
getSize()
Returns the length of the list or 0 if there's no list. |
Object |
remove(int index)
Removes the element at the specified position in this list. |
boolean |
remove(Object o)
Removes a single instance of the specified element from this list, if it is present (optional operation). |
void |
removeListDataListener(ListDataListener l)
Removes a listener from the list that's notified each time a change to the data model occurs. |
protected void |
removeRange(int fromIndex,
int toIndex)
Removes from this List all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive. |
Object |
set(int index,
Object element)
Replaces the element at the specified position in this list with the specified element. |
Methods inherited from class java.util.ArrayList |
---|
clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, size, toArray, toArray, trimToSize |
Methods inherited from class java.util.AbstractList |
---|
equals, hashCode, iterator, listIterator, listIterator, subList |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, removeAll, retainAll, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, removeAll, retainAll, size, subList, toArray, toArray |
Constructor Detail |
---|
public ArrayListModel()
public ArrayListModel(int initialCapacity)
initialCapacity
- the initial capacity of the list.
IllegalArgumentException
- if the specified initial capacity
is negativepublic ArrayListModel(Collection c)
ArrayListModel
instance has an initial capacity of
110% the size of the specified collection.
c
- the collection whose elements are to be placed into this list.
NullPointerException
- if the specified collection is
null
Method Detail |
---|
public void add(int index, Object element)
add
in interface List
add
in class ArrayList
index
- index at which the specified element is to be inserted.element
- element to be inserted.
IndexOutOfBoundsException
- if index is out of range
(index < 0 || index > size())
.public boolean add(Object o)
add
in interface Collection
add
in interface List
add
in class ArrayList
o
- element to be appended to this list.
true
(as per the general contract of Collection.add).public boolean addAll(int index, Collection c)
addAll
in interface List
addAll
in class ArrayList
index
- index at which to insert first element
from the specified collection.c
- elements to be inserted into this list.
true
if this list changed as a result of the call.
IndexOutOfBoundsException
- if index out of range (index
< 0 || index > size())
.
NullPointerException
- if the specified Collection is null.public boolean addAll(Collection c)
addAll
in interface Collection
addAll
in interface List
addAll
in class ArrayList
c
- the elements to be inserted into this list.
true
if this list changed as a result of the call.
NullPointerException
- if the specified collection is null.public void clear()
clear
in interface Collection
clear
in interface List
clear
in class ArrayList
public Object remove(int index)
remove
in interface List
remove
in class ArrayList
index
- the index of the element to removed.
IndexOutOfBoundsException
- if index out of range (index
< 0 || index >= size())
.public boolean remove(Object o)
This implementation looks for the index of the specified element.
If it finds the element, it removes the element at this index
by calling #remove(int)
that fires a ListDataEvent.
remove
in interface Collection
remove
in interface List
remove
in class ArrayList
o
- element to be removed from this list, if present.
protected void removeRange(int fromIndex, int toIndex)
(toIndex - fromIndex)
elements.
(If toIndex==fromIndex
, this operation has no effect.)
removeRange
in class ArrayList
fromIndex
- index of first element to be removed.toIndex
- index after last element to be removed.public Object set(int index, Object element)
set
in interface List
set
in class ArrayList
index
- index of element to replace.element
- element to be stored at the specified position.
IndexOutOfBoundsException
- if index out of range
(index < 0 || index >= size())
.public void addListDataListener(ListDataListener l)
addListDataListener
in interface ListModel
l
- the ListDataListener
to be addedpublic void removeListDataListener(ListDataListener l)
removeListDataListener
in interface ListModel
l
- the ListDataListener
to be removedpublic Object getElementAt(int index)
getElementAt
in interface ListModel
index
- the requested index
index
public int getSize()
getSize
in interface ListModel
public void fireContentsChanged(int index)
ListDataListeners
that the element
at the specified index has changed. Useful if there's a content change
without any structural change.This method must be called after the element of the list changes.
index
- the index of the element that has changedEventListenerList
public ListDataListener[] getListDataListeners()
ArrayListModel
.
ListDataListener
s,
or an empty array if no list data listeners
are currently registeredaddListDataListener(ListDataListener)
,
removeListDataListener(ListDataListener)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |