![]() ![]() ![]() |
22
Listener List
Features of JCListenerList
Classes
Examples
22.1 Features of JCListenerList
JCListenerList
is a class that assists with keeping track of event listeners in a thread-safe manner. The use of static methods on theJCListenerList
class prevents any problems from occurring if the list being modified is null. To send events to the listener in the list, simply get theJCListenerListEnumeration
of the list and walk through the elements. There is no ordering guarantee.
22.2 Classes
The following is a list of the
JCListenerList
classes:
Implements
java.util.Enumeration
and takes aJCListenerList
as its parameter. It defines methodshasMoreElements()
andnextElement()
.
22.3 Methods
The following is a list of the
JCListenerList
methods:
22.4 Examples
To add a listener using a
JCListenerList someList = null;JCListenerList
:
...
public synchronized void addSomeListener(SomeListener l) {
someList = JCListenerList.add(someList, l);
}
public synchronized void removeSomeListener(SomeListener l) {
someList = JCListenerList.remove(someList, l);
}The use of static methods on the
JCListenerList
class prevents any problems from occurring if the list being modified is null.To send events to the listener in the list, simply get the
Enumeration
of the list and walk through the elements. There is no ordering guarantee.
![]() ![]() ![]() |