javax.swing

Class AbstractListModel

public abstract class AbstractListModel extends Object implements ListModel, Serializable

Provides standard implementations of some methods in {@link ListModel}.
Field Summary
protected EventListenerListlistenerList
List of ListDataListeners called for each change to the list.
Constructor Summary
AbstractListModel()
Creates a new model instance - initialises the event listener list.
Method Summary
voidaddListDataListener(ListDataListener listener)
Add a listener object to this model.
protected voidfireContentsChanged(Object source, int startIndex, int endIndex)
Call {@link ListDataListener#contentsChanged} on each element of the {@link #listenerList} which is a {@link ListDataListener}.
protected voidfireIntervalAdded(Object source, int startIndex, int endIndex)
Call {@link ListDataListener#intervalAdded} on each element of the {@link #listenerList} which is a {@link ListDataListener}.
protected voidfireIntervalRemoved(Object source, int startIndex, int endIndex)
Call {@link ListDataListener#intervalRemoved} on each element of the {@link #listenerList} which is a {@link ListDataListener}.
ListDataListener[]getListDataListeners()
A synonym for getListeners(ListDataListener.class).
<T extends EventListener> T[]getListeners(Class<T> listenerType)
Return the subset of {@link EventListener} objects found in this object's {@link #listenerList} which are elements of the specified type.
voidremoveListDataListener(ListDataListener listener)
Add a listener object to this model.

Field Detail

listenerList

protected EventListenerList listenerList
List of ListDataListeners called for each change to the list.

Constructor Detail

AbstractListModel

public AbstractListModel()
Creates a new model instance - initialises the event listener list.

Method Detail

addListDataListener

public void addListDataListener(ListDataListener listener)
Add a listener object to this model. The listener will be called any time the set of elements in the model is changed.

Parameters: listener The listener to add

fireContentsChanged

protected void fireContentsChanged(Object source, int startIndex, int endIndex)
Call {@link ListDataListener#contentsChanged} on each element of the {@link #listenerList} which is a {@link ListDataListener}. The event fired has type {@link ListDataEvent#CONTENTS_CHANGED} and represents a change to the data elements in the range [startIndex, endIndex] inclusive.

Parameters: source The source of the change, typically this startIndex The index of the first element which changed endIndex The index of the last element which changed

fireIntervalAdded

protected void fireIntervalAdded(Object source, int startIndex, int endIndex)
Call {@link ListDataListener#intervalAdded} on each element of the {@link #listenerList} which is a {@link ListDataListener}. The event fired has type {@link ListDataEvent#INTERVAL_ADDED} and represents an addition of the data elements in the range [startIndex, endIndex] inclusive.

Parameters: source The source of the change, typically this startIndex The index of the first new element endIndex The index of the last new element

fireIntervalRemoved

protected void fireIntervalRemoved(Object source, int startIndex, int endIndex)
Call {@link ListDataListener#intervalRemoved} on each element of the {@link #listenerList} which is a {@link ListDataListener}. The event fired has type {@link ListDataEvent#INTERVAL_REMOVED} and represents a removal of the data elements in the range [startIndex, endIndex] inclusive.

Parameters: source The source of the change, typically this startIndex The index of the first element removed endIndex The index of the last element removed

getListDataListeners

public ListDataListener[] getListDataListeners()
A synonym for getListeners(ListDataListener.class).

Returns: The set of ListDataListeners found in the {@link #listenerList}

getListeners

public <T extends EventListener> T[] getListeners(Class<T> listenerType)
Return the subset of {@link EventListener} objects found in this object's {@link #listenerList} which are elements of the specified type.

Parameters: listenerType The type of listeners to select

Returns: The set of listeners of the specified type

removeListDataListener

public void removeListDataListener(ListDataListener listener)
Add a listener object to this model. The listener will no longer be called when the set of elements in the model is changed.

Parameters: listener The listener to remove