com.jgoodies.common.collect

Class ArrayListModel<E>

public class ArrayListModel<E> extends ArrayList<E> implements ObservableList<E>

Adds javax.swing.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.

Parameters: the type of the list elements

Version: $Revision: 1.2 $

Author: Karsten Lentzsch

See Also: ObservableList

Constructor Summary
ArrayListModel()
Constructs an empty list with an initial capacity of ten.
ArrayListModel(int initialCapacity)
Constructs an empty list with the specified initial capacity.
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.
Method Summary
voidaddListDataListener(ListDataListener l)
voidfireContentsChanged(int index)
Notifies all registered {@code ListDataListeners} that the element at the specified index has changed.
ObjectgetElementAt(int index)
ListDataListener[]getListDataListeners()
Returns an array of all the list data listeners registered on this {@code ArrayListModel}.
intgetSize()
voidremoveListDataListener(ListDataListener l)

Constructor Detail

ArrayListModel

public ArrayListModel()
Constructs an empty list with an initial capacity of ten.

ArrayListModel

public ArrayListModel(int initialCapacity)
Constructs an empty list with the specified initial capacity.

Parameters: initialCapacity the initial capacity of the list.

Throws: IllegalArgumentException if the specified initial capacity is negative

ArrayListModel

public 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. The {@code ArrayListModel} instance has an initial capacity of 110% the size of the specified collection.

Parameters: c the collection whose elements are to be placed into this list.

Throws: NullPointerException if the specified collection is {@code null}

Method Detail

addListDataListener

public final void addListDataListener(ListDataListener l)

fireContentsChanged

public final void fireContentsChanged(int index)
Notifies all registered {@code 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.

Parameters: index the index of the element that has changed

See Also: EventListenerList

getElementAt

public final Object getElementAt(int index)

getListDataListeners

public final ListDataListener[] getListDataListeners()
Returns an array of all the list data listeners registered on this {@code ArrayListModel}.

Returns: all of this model's {@code ListDataListener}s, or an empty array if no list data listeners are currently registered

See Also: addListDataListener removeListDataListener

getSize

public final int getSize()

removeListDataListener

public final void removeListDataListener(ListDataListener l)
Copyright © 2009-2010 JGoodies Karsten Lentzsch. All Rights Reserved.