Class AWTEventMulticaster

Class java.awt.AWTEventMulticaster

Class Members | This Package | All Packages
java.lang.Object
   |
   +----java.awt.AWTEventMulticaster

public class AWTEventMulticaster
extends Object
implements ComponentListener, ContainerListener, FocusListener, KeyListener, MouseListener, MouseMotionListener, WindowListener, ActionListener, ItemListener, AdjustmentListener, TextListener

A class which implements efficient and thread-safe multi-cast event dispatching for the AWT events defined in the java.awt.event package. This class will manage an immutable structure consisting of a chain of event listeners and will dispatch events to those listeners. Because the structure is immutable, it is safe to use this API to add/remove listeners during the process of an event dispatch operation. An example of how this class could be used to implement a new component which fires "action" events:


 public myComponent extends Component {
     ActionListener actionListener = null;
     public void addActionListener(ActionListener l) {
	   actionListener = AWTEventMulticaster.add(actionListener, l);
     }
     public void removeActionListener(ActionListener l) {
  	   actionListener = AWTEventMulticaster.remove(actionListener, l);
     }
     public void processEvent(AWTEvent e) {
         // when event occurs which causes "action" semantic
         if (actionListener != null) {
             actionListener.actionPerformed(new ActionEvent());
         }         
 }