java.awt

Class AWTEventMulticaster

  • java.lang.Object
    • java.awt.AWTEventMulticaster
  • All Implemented Interfaces:
    ActionListener, AdjustmentListener, ComponentListener, ContainerListener, FocusListener, HierarchyBoundsListener, HierarchyListener, InputMethodListener, ItemListener, KeyListener, MouseListener, MouseMotionListener, MouseWheelListener, TextListener, WindowFocusListener, WindowListener, WindowStateListener, java.util.EventListener
    AWTEventMulticaster implements efficient and thread-safe multi-cast event dispatching for the AWT events defined in the java.awt.event package.

    The following example illustrates how to use this class:

    
     public myComponent extends Component {
         ActionListener actionListener = null;
    
         public synchronized void addActionListener(ActionListener l) {
             actionListener = AWTEventMulticaster.add(actionListener, l);
         }
         public synchronized void removeActionListener(ActionListener l) {
             actionListener = AWTEventMulticaster.remove(actionListener, l);
         }
         public void processEvent(AWTEvent e) {
             // when event occurs which causes "action" semantic
             ActionListener listener = actionListener;
             if (listener != null) {
                 listener.actionPerformed(new ActionEvent());
             }
         }
     }
     
    The important point to note is the first argument to the add and remove methods is the field maintaining the listeners. In addition you must assign the result of the add and remove methods to the field maintaining the listeners.

    AWTEventMulticaster is implemented as a pair of EventListeners that are set at construction time. AWTEventMulticaster is immutable. The add and remove methods do not alter AWTEventMulticaster in anyway. If necessary, a new AWTEventMulticaster is created. In this way it is safe to add and remove listeners during the process of an event dispatching. However, event listeners added during the process of an event dispatch operation are not notified of the event currently being dispatched.

    All of the add methods allow null arguments. If the first argument is null, the second argument is returned. If the first argument is not null and the second argument is null, the first argument is returned. If both arguments are non-null, a new AWTEventMulticaster is created using the two arguments and returned.

    For the remove methods that take two arguments, the following is returned:

    • null, if the first argument is null, or the arguments are equal, by way of ==.
    • the first argument, if the first argument is not an instance of AWTEventMulticaster.
    • result of invoking remove(EventListener) on the first argument, supplying the second argument to the remove(EventListener) method.

    Swing makes use of EventListenerList for similar logic. Refer to it for details.

    Since:
    1.1
    See Also:
    EventListenerList
    • Static Methods 
      Modifier and Type Static Method and Description
      Ordinary member indicator add Reveal DetailHide Detail
      Adds action-listener-a with action-listener-b and returns the resulting multicast listener.
      Ordinary member indicator add Reveal DetailHide Detail
      Adds adjustment-listener-a with adjustment-listener-b and returns the resulting multicast listener.
      Ordinary member indicator add Reveal DetailHide Detail
      Adds component-listener-a with component-listener-b and returns the resulting multicast listener.
      Ordinary member indicator add Reveal DetailHide Detail
      Adds container-listener-a with container-listener-b and returns the resulting multicast listener.
      Ordinary member indicator add Reveal DetailHide Detail
      Adds focus-listener-a with focus-listener-b and returns the resulting multicast listener.
      Ordinary member indicator add Reveal DetailHide Detail
      Adds hierarchy-bounds-listener-a with hierarchy-bounds-listener-b and returns the resulting multicast listener.
      Ordinary member indicator add Reveal DetailHide Detail
      Adds hierarchy-listener-a with hierarchy-listener-b and returns the resulting multicast listener.
      Ordinary member indicator add Reveal DetailHide Detail
      Adds input-method-listener-a with input-method-listener-b and returns the resulting multicast listener.
      Ordinary member indicator add Reveal DetailHide Detail
      Adds item-listener-a with item-listener-b and returns the resulting multicast listener.
      Ordinary member indicator add Reveal DetailHide Detail
      Adds key-listener-a with key-listener-b and returns the resulting multicast listener.
      Ordinary member indicator add Reveal DetailHide Detail
      Adds mouse-listener-a with mouse-listener-b and returns the resulting multicast listener.
      Ordinary member indicator add Reveal DetailHide Detail
      Adds mouse-motion-listener-a with mouse-motion-listener-b and returns the resulting multicast listener.
      Ordinary member indicator add Reveal DetailHide Detail
      Adds mouse-wheel-listener-a with mouse-wheel-listener-b and returns the resulting multicast listener.
      Ordinary member indicator add Reveal DetailHide Detail
       
      Ordinary member indicator add Reveal DetailHide Detail
      Adds window-focus-listener-a with window-focus-listener-b and returns the resulting multicast listener.
      Ordinary member indicator add Reveal DetailHide Detail
      Adds window-listener-a with window-listener-b and returns the resulting multicast listener.
      Ordinary member indicator add Reveal DetailHide Detail
      Adds window-state-listener-a with window-state-listener-b and returns the resulting multicast listener.
      Ordinary member indicator getListeners Reveal DetailHide Detail
      Returns an array of all the objects chained as FooListeners by the specified java.util.EventListener.
      Ordinary member indicator remove Reveal DetailHide Detail
      Removes the old action-listener from action-listener-l and returns the resulting multicast listener.
      Ordinary member indicator remove Reveal DetailHide Detail
      Removes the old adjustment-listener from adjustment-listener-l and returns the resulting multicast listener.
      Ordinary member indicator remove Reveal DetailHide Detail
      Removes the old component-listener from component-listener-l and returns the resulting multicast listener.
      Ordinary member indicator remove Reveal DetailHide Detail
      Removes the old container-listener from container-listener-l and returns the resulting multicast listener.
      Ordinary member indicator remove Reveal DetailHide Detail
      Removes the old focus-listener from focus-listener-l and returns the resulting multicast listener.
      Ordinary member indicator remove Reveal DetailHide Detail
      Removes the old hierarchy-bounds-listener from hierarchy-bounds-listener-l and returns the resulting multicast listener.
      Ordinary member indicator remove Reveal DetailHide Detail
      Removes the old hierarchy-listener from hierarchy-listener-l and returns the resulting multicast listener.
      Ordinary member indicator remove Reveal DetailHide Detail
      Removes the old input-method-listener from input-method-listener-l and returns the resulting multicast listener.
      Ordinary member indicator remove Reveal DetailHide Detail
      Removes the old item-listener from item-listener-l and returns the resulting multicast listener.
      Ordinary member indicator remove Reveal DetailHide Detail
      Removes the old key-listener from key-listener-l and returns the resulting multicast listener.
      Ordinary member indicator remove Reveal DetailHide Detail
      Removes the old mouse-listener from mouse-listener-l and returns the resulting multicast listener.
      Ordinary member indicator remove Reveal DetailHide Detail
      Removes the old mouse-motion-listener from mouse-motion-listener-l and returns the resulting multicast listener.
      Ordinary member indicator remove Reveal DetailHide Detail
      Removes the old mouse-wheel-listener from mouse-wheel-listener-l and returns the resulting multicast listener.
      Ordinary member indicator remove Reveal DetailHide Detail
       
      Ordinary member indicator remove Reveal DetailHide Detail
      Removes the old window-focus-listener from window-focus-listener-l and returns the resulting multicast listener.
      Ordinary member indicator remove Reveal DetailHide Detail
      Removes the old window-listener from window-listener-l and returns the resulting multicast listener.
      Ordinary member indicator remove Reveal DetailHide Detail
      Removes the old window-state-listener from window-state-listener-l and returns the resulting multicast listener.
    • Methods 
      Modifier and Type Method and Description
      Ordinary member indicator actionPerformed Reveal DetailHide Detail
      Handles the actionPerformed event by invoking the actionPerformed methods on listener-a and listener-b.
      Ordinary member indicator adjustmentValueChanged Reveal DetailHide Detail
      Handles the adjustmentValueChanged event by invoking the adjustmentValueChanged methods on listener-a and listener-b.
      Ordinary member indicator ancestorMoved Reveal DetailHide Detail
      Handles the ancestorMoved event by invoking the ancestorMoved methods on listener-a and listener-b.
      Ordinary member indicator ancestorResized Reveal DetailHide Detail
      Handles the ancestorResized event by invoking the ancestorResized methods on listener-a and listener-b.
      Ordinary member indicator caretPositionChanged Reveal DetailHide Detail
      Handles the caretPositionChanged event by invoking the caretPositionChanged methods on listener-a and listener-b.
      Ordinary member indicator componentAdded Reveal DetailHide Detail
      Handles the componentAdded container event by invoking the componentAdded methods on listener-a and listener-b.
      Ordinary member indicator componentHidden Reveal DetailHide Detail
      Handles the componentHidden event by invoking the componentHidden methods on listener-a and listener-b.
      Ordinary member indicator componentMoved Reveal DetailHide Detail
      Handles the componentMoved event by invoking the componentMoved methods on listener-a and listener-b.
      Ordinary member indicator componentRemoved Reveal DetailHide Detail
      Handles the componentRemoved container event by invoking the componentRemoved methods on listener-a and listener-b.
      Ordinary member indicator componentResized Reveal DetailHide Detail
      Handles the componentResized event by invoking the componentResized methods on listener-a and listener-b.
      Ordinary member indicator componentShown Reveal DetailHide Detail
      Handles the componentShown event by invoking the componentShown methods on listener-a and listener-b.
      Ordinary member indicator focusGained Reveal DetailHide Detail
      Handles the focusGained event by invoking the focusGained methods on listener-a and listener-b.
      Ordinary member indicator focusLost Reveal DetailHide Detail
      Handles the focusLost event by invoking the focusLost methods on listener-a and listener-b.
      Ordinary member indicator hierarchyChanged Reveal DetailHide Detail
      Handles the hierarchyChanged event by invoking the hierarchyChanged methods on listener-a and listener-b.
      Ordinary member indicator inputMethodTextChanged Reveal DetailHide Detail
      Handles the inputMethodTextChanged event by invoking the inputMethodTextChanged methods on listener-a and listener-b.
      Ordinary member indicator itemStateChanged Reveal DetailHide Detail
      Handles the itemStateChanged event by invoking the itemStateChanged methods on listener-a and listener-b.
      Ordinary member indicator keyPressed Reveal DetailHide Detail
      Handles the keyPressed event by invoking the keyPressed methods on listener-a and listener-b.
      Ordinary member indicator keyReleased Reveal DetailHide Detail
      Handles the keyReleased event by invoking the keyReleased methods on listener-a and listener-b.
      Ordinary member indicator keyTyped Reveal DetailHide Detail
      Handles the keyTyped event by invoking the keyTyped methods on listener-a and listener-b.
      Ordinary member indicator mouseClicked Reveal DetailHide Detail
      Handles the mouseClicked event by invoking the mouseClicked methods on listener-a and listener-b.
      Ordinary member indicator mouseDragged Reveal DetailHide Detail
      Handles the mouseDragged event by invoking the mouseDragged methods on listener-a and listener-b.
      Ordinary member indicator mouseEntered Reveal DetailHide Detail
      Handles the mouseEntered event by invoking the mouseEntered methods on listener-a and listener-b.
      Ordinary member indicator mouseExited Reveal DetailHide Detail
      Handles the mouseExited event by invoking the mouseExited methods on listener-a and listener-b.
      Ordinary member indicator mouseMoved Reveal DetailHide Detail
      Handles the mouseMoved event by invoking the mouseMoved methods on listener-a and listener-b.
      Ordinary member indicator mousePressed Reveal DetailHide Detail
      Handles the mousePressed event by invoking the mousePressed methods on listener-a and listener-b.
      Ordinary member indicator mouseReleased Reveal DetailHide Detail
      Handles the mouseReleased event by invoking the mouseReleased methods on listener-a and listener-b.
      Ordinary member indicator mouseWheelMoved Reveal DetailHide Detail
      Handles the mouseWheelMoved event by invoking the mouseWheelMoved methods on listener-a and listener-b.
      Ordinary member indicator textValueChanged Reveal DetailHide Detail
      Invoked when the value of the text has changed.
      Ordinary member indicator windowActivated Reveal DetailHide Detail
      Handles the windowActivated event by invoking the windowActivated methods on listener-a and listener-b.
      Ordinary member indicator windowClosed Reveal DetailHide Detail
      Handles the windowClosed event by invoking the windowClosed methods on listener-a and listener-b.
      Ordinary member indicator windowClosing Reveal DetailHide Detail
      Handles the windowClosing event by invoking the windowClosing methods on listener-a and listener-b.
      Ordinary member indicator windowDeactivated Reveal DetailHide Detail
      Handles the windowDeactivated event by invoking the windowDeactivated methods on listener-a and listener-b.
      Ordinary member indicator windowDeiconified Reveal DetailHide Detail
      Handles the windowDeiconfied event by invoking the windowDeiconified methods on listener-a and listener-b.
      Ordinary member indicator windowGainedFocus Reveal DetailHide Detail
      Handles the windowGainedFocus event by invoking the windowGainedFocus methods on listener-a and listener-b.
      Ordinary member indicator windowIconified Reveal DetailHide Detail
      Handles the windowIconified event by invoking the windowIconified methods on listener-a and listener-b.
      Ordinary member indicator windowLostFocus Reveal DetailHide Detail
      Handles the windowLostFocus event by invoking the windowLostFocus methods on listener-a and listener-b.
      Ordinary member indicator windowOpened Reveal DetailHide Detail
      Handles the windowOpened event by invoking the windowOpened methods on listener-a and listener-b.
      Ordinary member indicator windowStateChanged Reveal DetailHide Detail
      Handles the windowStateChanged event by invoking the windowStateChanged methods on listener-a and listener-b.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
This document was created by Dulcet from the OpenJDK sources. Copyright © 1993, 2012 Oracle and/or its affiliates. All rights reserved.

SourceForge