public class EventListModel<E> extends Object implements ListEventListener<E>, ListModel
JList
. Each element of the list
corresponds to an element in the ListModel
.
The EventListModel 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)
.
SwingUtilities.invokeAndWait(Runnable)
Modifier and Type | Field and Description |
---|---|
protected org.jadice.util.glazedlists.gui.MutableListDataEvent |
listDataEvent
recycle the list data event to prevent unnecessary object creation
|
Constructor and Description |
---|
EventListModel(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 . |
Modifier and Type | Method and Description |
---|---|
void |
addListDataListener(ListDataListener listDataListener)
Registers the specified ListDataListener to receive updates whenever
this list changes.
|
void |
dispose()
Releases the resources consumed by this
EventListModel so that it
may eventually be garbage collected. |
protected void |
fireListDataEvent(ListDataEvent listDataEvent)
Notifies all ListDataListeners about one block of changes in the list.
|
Object |
getElementAt(int index)
Retrieves the value at the specified location from the table.
|
int |
getSize()
Gets the size of the list.
|
void |
listChanged(ListEvent<E> listChanges)
For implementing the ListEventListener interface.
|
void |
removeListDataListener(ListDataListener listDataListener)
Unregisters the specified ListDataListener from receiving updates
whenever this list changes.
|
protected final org.jadice.util.glazedlists.gui.MutableListDataEvent listDataEvent
public 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 Object getElementAt(int index)
getElementAt
in interface ListModel
ListTable
public int getSize()
public void addListDataListener(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 ListModel
public void removeListDataListener(ListDataListener listDataListener)
removeListDataListener
in interface ListModel
protected void fireListDataEvent(ListDataEvent listDataEvent)
public void dispose()
EventListModel
so that it
may eventually be garbage collected.
An EventListModel
will be garbage collected without a call to
#dispose()
, but not before its source EventList
is garbage
collected. By calling #dispose()
, you allow the EventListModel
to be garbage collected before its source EventList
. This is
necessary for situations where an EventListModel
is short-lived but
its source EventList
is long-lived.
Warning: It is an error
to call any method on an EventListModel
after it has been disposed.
As such, this EventListModel
should be detached from its
corresponding Component before it is disposed.
Copyright © 2024 levigo holding gmbh. All rights reserved.