public final class ListenerList<T extends EventListener> extends Object implements Serializable
Constructor and Description |
---|
ListenerList() |
Modifier and Type | Method and Description |
---|---|
void |
add(T listener)
Adds the given listener to this listener list.
|
int |
getListenerCount()
Returns the total number of listeners for this listener list.
|
List<T> |
getListeners()
Returns a list of listeners.
|
void |
remove(T listener)
Removes the given listener from this listener list.
|
String |
toString() |
public List<T> getListeners()
The listeners are returned in exactly the same order as they were added to this list. Use the following code for firing events to all the listeners you get from this method.
List<MyListener> listeners = listenerList.getListeners();
for (MyListener l : listeners) {
l.notify(evt);
}
public int getListenerCount()
public void add(T listener)
listener
- the listener to be added. If null is passed it is ignored (nothing gets added).public void remove(T listener)
listener
- the listener to be removed. If null is passed it is ignored (nothing gets removed).