|
||||||||||
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<E>
com.jgoodies.binding.list.ArrayListModel<E>
E
- the type of the list elementspublic final class ArrayListModel<E>
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.
Field Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
ArrayListModel()
Constructs an empty list with an initial capacity of ten. |
|
ArrayListModel(Collection<? extends E> 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 | |
---|---|
boolean |
add(E e)
Appends the specified element to the end of this list. |
void |
add(int index,
E element)
Inserts the specified element at the specified position in this list. |
boolean |
addAll(Collection<? extends E> 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<? extends E> 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. |
E |
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. |
E |
set(int index,
E 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, iterator, lastIndexOf, listIterator, listIterator, removeAll, retainAll, size, subList, toArray, toArray, trimToSize |
Methods inherited from class java.util.AbstractList |
---|
equals, hashCode |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, 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<? extends E> 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, E element)
add
in interface List<E>
add
in class ArrayList<E>
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(E e)
add
in interface Collection<E>
add
in interface List<E>
add
in class ArrayList<E>
e
- element to be appended to this list.
true
(as per the general contract of Collection.add).public boolean addAll(int index, Collection<? extends E> c)
addAll
in interface List<E>
addAll
in class ArrayList<E>
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<? extends E> c)
addAll
in interface Collection<E>
addAll
in interface List<E>
addAll
in class ArrayList<E>
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<E>
clear
in interface List<E>
clear
in class ArrayList<E>
public E remove(int index)
remove
in interface List<E>
remove
in class ArrayList<E>
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<E>
remove
in interface List<E>
remove
in class ArrayList<E>
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<E>
fromIndex
- index of first element to be removed.toIndex
- index after last element to be removed.public E set(int index, E element)
set
in interface List<E>
set
in class ArrayList<E>
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 |