public class DefaultEventListModel<E> extends java.lang.Object implements ListEventListener<E>, javax.swing.ListModel
JList. Each element of the list
corresponds to an element in the ListModel.
The DefaultEventListModel class is not thread-safe. Unless
otherwise noted, all methods are only safe to be called from the event
dispatch thread. To do this programmatically, use SwingUtilities.invokeAndWait(Runnable)
and wrap the source list (or some part of the source list's pipeline) using
GlazedListsSwing.swingThreadProxyList(EventList).
SwingUtilities.invokeAndWait(Runnable)| Modifier and Type | Field and Description |
|---|---|
protected ca.odell.glazedlists.swing.MutableListDataEvent |
listDataEvent
recycle the list data event to prevent unnecessary object creation
|
protected EventList<E> |
source
the source EventList
|
| Modifier | Constructor and Description |
|---|---|
|
DefaultEventListModel(EventList<E> source)
Creates a new model that contains all objects located in the given
source and reacts to any changes in the given
source. |
protected |
DefaultEventListModel(EventList<E> source,
boolean disposeSource)
Creates a new model that contains all objects located in the given
source and reacts to any changes in the given
source. |
| Modifier and Type | Method and Description |
|---|---|
void |
addListDataListener(javax.swing.event.ListDataListener listDataListener)
Registers the specified ListDataListener to receive updates whenever
this list changes.
|
void |
dispose()
Releases the resources consumed by this
DefaultEventListModel so that it
may eventually be garbage collected. |
protected void |
fireListDataEvent(javax.swing.event.ListDataEvent listDataEvent)
Notifies all ListDataListeners about one block of changes in the list.
|
java.lang.Object |
getElementAt(int index)
Returns the value at the specified index.
|
int |
getSize()
Gets the size of the list.
|
void |
listChanged(ListEvent<E> listChanges)
For implementing the ListEventListener interface.
|
void |
removeListDataListener(javax.swing.event.ListDataListener listDataListener)
Deregisters the specified ListDataListener from receiving updates
whenever this list changes.
|
protected final ca.odell.glazedlists.swing.MutableListDataEvent listDataEvent
public DefaultEventListModel(EventList<E> source)
source and reacts to any changes in the given
source.source - the EventList that provides the elementsprotected DefaultEventListModel(EventList<E> source, boolean disposeSource)
source and reacts to any changes in the given
source.source - the EventList that provides the elementsdiposeSource - true if the source list should be disposed when disposing
this model, false otherwisepublic void listChanged(ListEvent<E> listChanges)
This always sends discrete changes for the complete size of the list. It may be more efficient to implement a threshhold where a large list of changes are grouped together as a single change. This is how the ListTable accepts large change events.
listChanged in interface ListEventListener<E>listChanges - a ListEvent describing the changes to the listpublic java.lang.Object getElementAt(int index)
getElementAt in interface javax.swing.ListModelindex - the requested indexindexpublic int getSize()
getSize in interface javax.swing.ListModelpublic void addListDataListener(javax.swing.event.ListDataListener listDataListener)
The specified ListDataListener must not save a reference to the ListDataEvent beyond the end of the notification method. This is because the ListDataEvent is re-used to increase the performance of this implementation.
addListDataListener in interface javax.swing.ListModelpublic void removeListDataListener(javax.swing.event.ListDataListener listDataListener)
removeListDataListener in interface javax.swing.ListModelprotected void fireListDataEvent(javax.swing.event.ListDataEvent listDataEvent)
public void dispose()
DefaultEventListModel so that it
may eventually be garbage collected.
An DefaultEventListModel will be garbage collected without a call to
dispose(), but not before its source EventList is garbage
collected. By calling dispose(), you allow the DefaultEventListModel
to be garbage collected before its source EventList. This is
necessary for situations where an DefaultEventListModel is short-lived but
its source EventList is long-lived.
Warning: It is an error
to call any method on an DefaultEventListModel after it has been disposed.
As such, this DefaultEventListModel should be detached from its
corresponding Component before it is disposed.
Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by buildd at 2016-02-14 5:12