Sample Code: Console Listeners
public class VProcMgr implements Tool, VConsoleActionListener {
private Vector consoleListeners = new Vector();
...
/**
* Adds the specified console actions listener to receive events for actions
* by our subcomponents.
*
* @param listener the console action listener to forward events to
*/
public void addConsoleActionListener(VConsoleActionListener listener) {
if (listener != null)
consoleListeners.addElement(listener);
} // addConsoleActionlistener
/**
* Notify all registered listeners of the specified console event.
*
* @param e the console action event
*/
public void fireConsoleAction(VConsoleEvent e) {
for (int i = 0; i < consoleListeners.size(); i++) {
VConsoleActionListener l = (VConsoleActionListener)
consoleListeners.elementAt(i);
l.consoleAction(e);
}
} // fireConsoleAction
...
VConsoleEvent ev = new VConsoleEvent(...);
fireConsoleAction(ev);
...
}