com.jgoodies.common.collect

Class LinkedListModel<E>

public class LinkedListModel<E> extends LinkedList<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
LinkedListModel()
Constructs an empty LinkedListModel.
LinkedListModel(Collection<? extends E> c)
Constructs a LinkedListModel 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.
EgetElementAt(int index)
ListDataListener[]getListDataListeners()
Returns an array of all the list data listeners registered on this {@code LinkedListModel}.
intgetSize()
voidremoveListDataListener(ListDataListener l)

Constructor Detail

LinkedListModel

public LinkedListModel()
Constructs an empty LinkedListModel.

LinkedListModel

public LinkedListModel(Collection<? extends E> c)
Constructs a LinkedListModel containing the elements of the specified collection, in the order they are returned by the collection's iterator.

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

Throws: NullPointerException if {@code c} 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 E getElementAt(int index)

getListDataListeners

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

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.