com.jgoodies.common.collect
E
- the type of the list elementspublic class ArrayListModel<E> extends java.util.ArrayList<E> implements ObservableList<E>
ListModel
capabilities to its superclass.
It allows to observe changes in the content and structure. Useful for
Lists that are bound to list views such as JList, JComboBox and JTable.This class should be be final and it will be marked final in a future version, if its subclass in the JGoodies Binding has been removed.
ObservableList
,
LinkedListModel
,
Serialized FormConstructor and Description |
---|
ArrayListModel()
Constructs an empty list with an initial capacity of ten.
|
ArrayListModel(java.util.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.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E e) |
void |
add(int index,
E element) |
boolean |
addAll(java.util.Collection<? extends E> c) |
boolean |
addAll(int index,
java.util.Collection<? extends E> c) |
void |
addListDataListener(javax.swing.event.ListDataListener l) |
void |
clear() |
void |
fireContentsChanged(int index)
Notifies all registered
ListDataListeners that the element
at the specified index has changed. |
java.lang.Object |
getElementAt(int index) |
javax.swing.event.ListDataListener[] |
getListDataListeners()
Returns an array of all the list data listeners
registered on this
ArrayListModel . |
int |
getSize() |
E |
remove(int index) |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection<?> c)
Removes from this collection all of its elements that are contained in
the specified collection (optional operation).
|
void |
removeListDataListener(javax.swing.event.ListDataListener l) |
protected void |
removeRange(int fromIndex,
int toIndex) |
boolean |
retainAll(java.util.Collection<?> c)
Retains only the elements in this collection that are contained in the
specified collection (optional operation).
|
E |
set(int index,
E element) |
clone, contains, ensureCapacity, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, size, subList, toArray, toArray, trimToSize
public ArrayListModel()
public ArrayListModel(int initialCapacity)
initialCapacity
- the initial capacity of the list.java.lang.IllegalArgumentException
- if the specified initial capacity
is negativepublic ArrayListModel(java.util.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.java.lang.NullPointerException
- if the specified collection is
null
public final void add(int index, E element)
public final boolean add(E e)
public final boolean addAll(int index, java.util.Collection<? extends E> c)
public final boolean addAll(java.util.Collection<? extends E> c)
public boolean removeAll(java.util.Collection<?> c)
This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's so contained, it's removed from this collection with the iterator's remove method.
Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements in common with the specified collection.
removeAll
in interface java.util.Collection<E>
removeAll
in interface java.util.List<E>
removeAll
in class java.util.ArrayList<E>
c
- elements to be removed from this collection.java.lang.UnsupportedOperationException
- if the removeAll method
is not supported by this collection.java.lang.NullPointerException
- if the specified collection is null.remove(Object)
,
ArrayList.contains(Object)
public boolean retainAll(java.util.Collection<?> c)
This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's not so contained, it's removed from this collection with the iterator's remove method.
Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements not present in the specified collection.
retainAll
in interface java.util.Collection<E>
retainAll
in interface java.util.List<E>
retainAll
in class java.util.ArrayList<E>
c
- elements to be retained in this collection.java.lang.UnsupportedOperationException
- if the retainAll method
is not supported by this Collection.java.lang.NullPointerException
- if the specified collection is null.remove(Object)
,
ArrayList.contains(Object)
public final void clear()
public final E remove(int index)
public final boolean remove(java.lang.Object o)
protected final void removeRange(int fromIndex, int toIndex)
removeRange
in class java.util.ArrayList<E>
public final void addListDataListener(javax.swing.event.ListDataListener l)
addListDataListener
in interface javax.swing.ListModel
public final void removeListDataListener(javax.swing.event.ListDataListener l)
removeListDataListener
in interface javax.swing.ListModel
public final java.lang.Object getElementAt(int index)
getElementAt
in interface javax.swing.ListModel
public final int getSize()
getSize
in interface javax.swing.ListModel
public final 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 final javax.swing.event.ListDataListener[] getListDataListeners()
ArrayListModel
.ListDataListener
s,
or an empty array if no list data listeners
are currently registeredaddListDataListener(ListDataListener)
,
removeListDataListener(ListDataListener)
Copyright © 2009-2011 JGoodies Karsten Lentzsch. All Rights Reserved.