edu.rice.cs.plt.swing
Class ComposedListener<T>
java.lang.Object
edu.rice.cs.plt.swing.ComposedListener<T>
- Direct Known Subclasses:
- ComposedActionListener, ComposedCaretListener, ComposedCellEditorListener, ComposedChangeListener, ComposedDocumentListener, ComposedTreeModelListener
public abstract class ComposedListener<T>
- extends Object
Abstract parent of composed listeners, which allow a list to be treated as a single
listener object. Subclasses should implement some listener interface and, for each method
in that interface, traverse the result of #listeners and delegate. For
example:
public class ComposedFooListener extends ComposedListener implements FooListener {
public void handleFooEvent1(FooEvent1 e) {
for (FooListener l : listeners()) { l.handleFooEvent1(e); }
}
public void handleFooEvent2(FooEvent2 e) {
for (FooListener l : listeners()) { l.handleFooEvent2(e); }
}
}
Following the convention of javax.swing.event.EventListenerList, the encapsulated list is
treated like a stack: traversal always returns the last-added element first; removal will match the
most recently-added listener equal to the provided listener.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ComposedListener
public ComposedListener()
add
public void add(T listener)
remove
public void remove(T listener)
listeners
protected Iterable<T> listeners()