org.netbeans.editor
Class WeakEventListenerList
java.lang.Object
javax.swing.event.EventListenerList
org.netbeans.editor.WeakEventListenerList
- All Implemented Interfaces:
- Serializable
public class WeakEventListenerList
- extends EventListenerList
Class that can hold the list of event listeners
in a "weak" manner. The advantage is that the listener
doesn't need to be explicitly removed. Because of the use
of the WeakReference it gets forgotten
automatically if it was garbage collected. There must
be at least one non-weak reference to the listener
(otherwise it would become garbage-collected).
One of the ways is to store the listener in some instance
variable in the class that adds the listener.
Please note that the methods getListenerCount()
and getListenerCount(Class t) give the count
that doesn't reflect whether some listeners were garbage
collected.
- See Also:
- Serialized Form
WeakEventListenerList
public WeakEventListenerList()
getListenerList
public Object[] getListenerList()
- Overrides:
getListenerList in class EventListenerList
getListeners
public EventListener[] getListeners(Class t)
- Overrides:
getListeners in class EventListenerList
add
public void add(Class t,
EventListener l)
- Adds the listener as a listener of the specified type.
- Overrides:
add in class EventListenerList
- Parameters:
t - the type of the listener to be addedl - the listener to be added
remove
public void remove(Class t,
EventListener l)
- Removes the listener as a listener of the specified type.
- Overrides:
remove in class EventListenerList
- Parameters:
t - the type of the listener to be removedl - the listener to be removed
toString
public String toString()
- Overrides:
toString in class EventListenerList