java.lang.Object | |
↳ | java.awt.AWTEventMulticaster |
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 ==
.
AWTEventMulticaster
.
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.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
a | |||||||||||
b |
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates an event multicaster instance which chains listener-a
with listener-b.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Handles the actionPerformed event by invoking the
actionPerformed methods on listener-a and listener-b.
| |||||||||||
Adds action-listener-a with action-listener-b and
returns the resulting multicast listener.
| |||||||||||
Adds container-listener-a with container-listener-b and
returns the resulting multicast listener.
| |||||||||||
Adds adjustment-listener-a with adjustment-listener-b and
returns the resulting multicast listener.
| |||||||||||
Adds item-listener-a with item-listener-b and
returns the resulting multicast listener.
| |||||||||||
Adds window-state-listener-a with window-state-listener-b
and returns the resulting multicast listener.
| |||||||||||
Adds mouse-wheel-listener-a with mouse-wheel-listener-b and
returns the resulting multicast listener.
| |||||||||||
Adds key-listener-a with key-listener-b and
returns the resulting multicast listener.
| |||||||||||
Adds focus-listener-a with focus-listener-b and
returns the resulting multicast listener.
| |||||||||||
Adds hierarchy-listener-a with hierarchy-listener-b and
returns the resulting multicast listener.
| |||||||||||
Adds mouse-listener-a with mouse-listener-b and
returns the resulting multicast listener.
| |||||||||||
Adds window-focus-listener-a with window-focus-listener-b
and returns the resulting multicast listener.
| |||||||||||
Adds window-listener-a with window-listener-b and
returns the resulting multicast listener.
| |||||||||||
Adds component-listener-a with component-listener-b and
returns the resulting multicast listener.
| |||||||||||
Adds input-method-listener-a with input-method-listener-b and
returns the resulting multicast listener.
| |||||||||||
Adds mouse-motion-listener-a with mouse-motion-listener-b and
returns the resulting multicast listener.
| |||||||||||
Adds hierarchy-bounds-listener-a with hierarchy-bounds-listener-b and
returns the resulting multicast listener.
| |||||||||||
Handles the adjustmentValueChanged event by invoking the
adjustmentValueChanged methods on listener-a and listener-b.
| |||||||||||
Handles the ancestorMoved event by invoking the
ancestorMoved methods on listener-a and listener-b.
| |||||||||||
Handles the ancestorResized event by invoking the
ancestorResized methods on listener-a and listener-b.
| |||||||||||
Handles the caretPositionChanged event by invoking the
caretPositionChanged methods on listener-a and listener-b.
| |||||||||||
Handles the componentAdded container event by invoking the
componentAdded methods on listener-a and listener-b.
| |||||||||||
Handles the componentHidden event by invoking the
componentHidden methods on listener-a and listener-b.
| |||||||||||
Handles the componentMoved event by invoking the
componentMoved methods on listener-a and listener-b.
| |||||||||||
Handles the componentRemoved container event by invoking the
componentRemoved methods on listener-a and listener-b.
| |||||||||||
Handles the componentResized event by invoking the
componentResized methods on listener-a and listener-b.
| |||||||||||
Handles the componentShown event by invoking the
componentShown methods on listener-a and listener-b.
| |||||||||||
Handles the focusGained event by invoking the
focusGained methods on listener-a and listener-b.
| |||||||||||
Handles the focusLost event by invoking the
focusLost methods on listener-a and listener-b.
| |||||||||||
Returns an array of all the objects chained as
FooListener s by the specified
java.util.EventListener . | |||||||||||
Handles the hierarchyChanged event by invoking the
hierarchyChanged methods on listener-a and listener-b.
| |||||||||||
Handles the inputMethodTextChanged event by invoking the
inputMethodTextChanged methods on listener-a and listener-b.
| |||||||||||
Handles the itemStateChanged event by invoking the
itemStateChanged methods on listener-a and listener-b.
| |||||||||||
Handles the keyPressed event by invoking the
keyPressed methods on listener-a and listener-b.
| |||||||||||
Handles the keyReleased event by invoking the
keyReleased methods on listener-a and listener-b.
| |||||||||||
Handles the keyTyped event by invoking the
keyTyped methods on listener-a and listener-b.
| |||||||||||
Handles the mouseClicked event by invoking the
mouseClicked methods on listener-a and listener-b.
| |||||||||||
Handles the mouseDragged event by invoking the
mouseDragged methods on listener-a and listener-b.
| |||||||||||
Handles the mouseEntered event by invoking the
mouseEntered methods on listener-a and listener-b.
| |||||||||||
Handles the mouseExited event by invoking the
mouseExited methods on listener-a and listener-b.
| |||||||||||
Handles the mouseMoved event by invoking the
mouseMoved methods on listener-a and listener-b.
| |||||||||||
Handles the mousePressed event by invoking the
mousePressed methods on listener-a and listener-b.
| |||||||||||
Handles the mouseReleased event by invoking the
mouseReleased methods on listener-a and listener-b.
| |||||||||||
Handles the mouseWheelMoved event by invoking the
mouseWheelMoved methods on listener-a and listener-b.
| |||||||||||
Removes the old hierarchy-bounds-listener from
hierarchy-bounds-listener-l and returns the resulting multicast
listener.
| |||||||||||
Removes the old hierarchy-listener from hierarchy-listener-l and
returns the resulting multicast listener.
| |||||||||||
Removes the old component-listener from component-listener-l and
returns the resulting multicast listener.
| |||||||||||
Removes the old mouse-motion-listener from mouse-motion-listener-l
and returns the resulting multicast listener.
| |||||||||||
Removes the old action-listener from action-listener-l and
returns the resulting multicast listener.
| |||||||||||
Removes the old window-focus-listener from window-focus-listener-l
and returns the resulting multicast listener.
| |||||||||||
Removes the old container-listener from container-listener-l and
returns the resulting multicast listener.
| |||||||||||
Removes the old item-listener from item-listener-l and
returns the resulting multicast listener.
| |||||||||||
Removes the old window-state-listener from window-state-listener-l
and returns the resulting multicast listener.
| |||||||||||
Removes the old focus-listener from focus-listener-l and
returns the resulting multicast listener.
| |||||||||||
Removes the old input-method-listener from input-method-listener-l and
returns the resulting multicast listener.
| |||||||||||
Removes the old mouse-wheel-listener from mouse-wheel-listener-l
and returns the resulting multicast listener.
| |||||||||||
Removes the old window-listener from window-listener-l and
returns the resulting multicast listener.
| |||||||||||
Removes the old adjustment-listener from adjustment-listener-l and
returns the resulting multicast listener.
| |||||||||||
Removes the old mouse-listener from mouse-listener-l and
returns the resulting multicast listener.
| |||||||||||
Removes the old key-listener from key-listener-l and
returns the resulting multicast listener.
| |||||||||||
Invoked when the value of the text has changed.
| |||||||||||
Handles the windowActivated event by invoking the
windowActivated methods on listener-a and listener-b.
| |||||||||||
Handles the windowClosed event by invoking the
windowClosed methods on listener-a and listener-b.
| |||||||||||
Handles the windowClosing event by invoking the
windowClosing methods on listener-a and listener-b.
| |||||||||||
Handles the windowDeactivated event by invoking the
windowDeactivated methods on listener-a and listener-b.
| |||||||||||
Handles the windowDeiconfied event by invoking the
windowDeiconified methods on listener-a and listener-b.
| |||||||||||
Handles the windowGainedFocus event by invoking the windowGainedFocus
methods on listener-a and listener-b.
| |||||||||||
Handles the windowIconified event by invoking the
windowIconified methods on listener-a and listener-b.
| |||||||||||
Handles the windowLostFocus event by invoking the windowLostFocus
methods on listener-a and listener-b.
| |||||||||||
Handles the windowOpened event by invoking the
windowOpened methods on listener-a and listener-b.
| |||||||||||
Handles the windowStateChanged event by invoking the
windowStateChanged methods on listener-a and listener-b.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the resulting multicast listener from adding listener-a
and listener-b together.
| |||||||||||
Removes a listener from this multicaster.
| |||||||||||
Returns the resulting multicast listener after removing the
old listener from listener-l.
| |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.awt.event.ActionListener
| |||||||||||
From interface
java.awt.event.AdjustmentListener
| |||||||||||
From interface
java.awt.event.ComponentListener
| |||||||||||
From interface
java.awt.event.ContainerListener
| |||||||||||
From interface
java.awt.event.FocusListener
| |||||||||||
From interface
java.awt.event.HierarchyBoundsListener
| |||||||||||
From interface
java.awt.event.HierarchyListener
| |||||||||||
From interface
java.awt.event.InputMethodListener
| |||||||||||
From interface
java.awt.event.ItemListener
| |||||||||||
From interface
java.awt.event.KeyListener
| |||||||||||
From interface
java.awt.event.MouseListener
| |||||||||||
From interface
java.awt.event.MouseMotionListener
| |||||||||||
From interface
java.awt.event.MouseWheelListener
| |||||||||||
From interface
java.awt.event.TextListener
| |||||||||||
From interface
java.awt.event.WindowFocusListener
| |||||||||||
From interface
java.awt.event.WindowListener
| |||||||||||
From interface
java.awt.event.WindowStateListener
|
Creates an event multicaster instance which chains listener-a
with listener-b. Input parameters a
and b
should not be null
, though implementations may vary in
choosing whether or not to throw NullPointerException
in that case.
a | listener-a |
---|---|
b | listener-b |
Handles the actionPerformed event by invoking the actionPerformed methods on listener-a and listener-b.
e | the action event |
---|
Adds action-listener-a with action-listener-b and returns the resulting multicast listener.
a | action-listener-a |
---|---|
b | action-listener-b |
Adds container-listener-a with container-listener-b and returns the resulting multicast listener.
a | container-listener-a |
---|---|
b | container-listener-b |
Adds adjustment-listener-a with adjustment-listener-b and returns the resulting multicast listener.
a | adjustment-listener-a |
---|---|
b | adjustment-listener-b |
Adds item-listener-a with item-listener-b and returns the resulting multicast listener.
a | item-listener-a |
---|---|
b | item-listener-b |
Adds window-state-listener-a with window-state-listener-b and returns the resulting multicast listener.
a | window-state-listener-a |
---|---|
b | window-state-listener-b |
Adds mouse-wheel-listener-a with mouse-wheel-listener-b and returns the resulting multicast listener.
a | mouse-wheel-listener-a |
---|---|
b | mouse-wheel-listener-b |
Adds key-listener-a with key-listener-b and returns the resulting multicast listener.
a | key-listener-a |
---|---|
b | key-listener-b |
Adds focus-listener-a with focus-listener-b and returns the resulting multicast listener.
a | focus-listener-a |
---|---|
b | focus-listener-b |
Adds hierarchy-listener-a with hierarchy-listener-b and returns the resulting multicast listener.
a | hierarchy-listener-a |
---|---|
b | hierarchy-listener-b |
Adds mouse-listener-a with mouse-listener-b and returns the resulting multicast listener.
a | mouse-listener-a |
---|---|
b | mouse-listener-b |
Adds window-focus-listener-a with window-focus-listener-b and returns the resulting multicast listener.
a | window-focus-listener-a |
---|---|
b | window-focus-listener-b |
Adds window-listener-a with window-listener-b and returns the resulting multicast listener.
a | window-listener-a |
---|---|
b | window-listener-b |
Adds component-listener-a with component-listener-b and returns the resulting multicast listener.
a | component-listener-a |
---|---|
b | component-listener-b |
Adds input-method-listener-a with input-method-listener-b and returns the resulting multicast listener.
a | input-method-listener-a |
---|---|
b | input-method-listener-b |
Adds mouse-motion-listener-a with mouse-motion-listener-b and returns the resulting multicast listener.
a | mouse-motion-listener-a |
---|---|
b | mouse-motion-listener-b |
Adds hierarchy-bounds-listener-a with hierarchy-bounds-listener-b and returns the resulting multicast listener.
a | hierarchy-bounds-listener-a |
---|---|
b | hierarchy-bounds-listener-b |
Handles the adjustmentValueChanged event by invoking the adjustmentValueChanged methods on listener-a and listener-b.
e | the adjustment event |
---|
Handles the ancestorMoved event by invoking the ancestorMoved methods on listener-a and listener-b.
e | the item event |
---|
Handles the ancestorResized event by invoking the ancestorResized methods on listener-a and listener-b.
e | the item event |
---|
Handles the caretPositionChanged event by invoking the caretPositionChanged methods on listener-a and listener-b.
e | the item event |
---|
Handles the componentAdded container event by invoking the componentAdded methods on listener-a and listener-b.
e | the component event |
---|
Handles the componentHidden event by invoking the componentHidden methods on listener-a and listener-b.
e | the component event |
---|
Handles the componentMoved event by invoking the componentMoved methods on listener-a and listener-b.
e | the component event |
---|
Handles the componentRemoved container event by invoking the componentRemoved methods on listener-a and listener-b.
e | the component event |
---|
Handles the componentResized event by invoking the componentResized methods on listener-a and listener-b.
e | the component event |
---|
Handles the componentShown event by invoking the componentShown methods on listener-a and listener-b.
e | the component event |
---|
Handles the focusGained event by invoking the focusGained methods on listener-a and listener-b.
e | the focus event |
---|
Handles the focusLost event by invoking the focusLost methods on listener-a and listener-b.
e | the focus event |
---|
Returns an array of all the objects chained as
FooListener
s by the specified
java.util.EventListener
.
FooListener
s are chained by the
AWTEventMulticaster
using the
addFooListener
method.
If a null
listener is specified, this method returns an
empty array. If the specified listener is not an instance of
AWTEventMulticaster
, this method returns an array which
contains only the specified listener. If no such listeners are chanined,
this method returns an empty array.
l | the specified java.util.EventListener |
---|---|
listenerType | the type of listeners requested; this parameter
should specify an interface that descends from
java.util.EventListener |
FooListener
s by the specified multicast
listener, or an empty array if no such listeners have been
chained by the specified multicast listenerNullPointerException | if the specified
listenertype parameter is null |
---|---|
ClassCastException | if listenerType
doesn't specify a class or interface that implements
java.util.EventListener |
Handles the hierarchyChanged event by invoking the hierarchyChanged methods on listener-a and listener-b.
e | the item event |
---|
Handles the inputMethodTextChanged event by invoking the inputMethodTextChanged methods on listener-a and listener-b.
e | the item event |
---|
Handles the itemStateChanged event by invoking the itemStateChanged methods on listener-a and listener-b.
e | the item event |
---|
Handles the keyPressed event by invoking the keyPressed methods on listener-a and listener-b.
e | the key event |
---|
Handles the keyReleased event by invoking the keyReleased methods on listener-a and listener-b.
e | the key event |
---|
Handles the keyTyped event by invoking the keyTyped methods on listener-a and listener-b.
e | the key event |
---|
Handles the mouseClicked event by invoking the mouseClicked methods on listener-a and listener-b.
e | the mouse event |
---|
Handles the mouseDragged event by invoking the mouseDragged methods on listener-a and listener-b.
e | the mouse event |
---|
Handles the mouseEntered event by invoking the mouseEntered methods on listener-a and listener-b.
e | the mouse event |
---|
Handles the mouseExited event by invoking the mouseExited methods on listener-a and listener-b.
e | the mouse event |
---|
Handles the mouseMoved event by invoking the mouseMoved methods on listener-a and listener-b.
e | the mouse event |
---|
Handles the mousePressed event by invoking the mousePressed methods on listener-a and listener-b.
e | the mouse event |
---|
Handles the mouseReleased event by invoking the mouseReleased methods on listener-a and listener-b.
e | the mouse event |
---|
Handles the mouseWheelMoved event by invoking the mouseWheelMoved methods on listener-a and listener-b.
e | the mouse event |
---|
Removes the old hierarchy-bounds-listener from hierarchy-bounds-listener-l and returns the resulting multicast listener.
l | hierarchy-bounds-listener-l |
---|---|
oldl | the hierarchy-bounds-listener being removed |
Removes the old hierarchy-listener from hierarchy-listener-l and returns the resulting multicast listener.
l | hierarchy-listener-l |
---|---|
oldl | the hierarchy-listener being removed |
Removes the old component-listener from component-listener-l and returns the resulting multicast listener.
l | component-listener-l |
---|---|
oldl | the component-listener being removed |
Removes the old mouse-motion-listener from mouse-motion-listener-l and returns the resulting multicast listener.
l | mouse-motion-listener-l |
---|---|
oldl | the mouse-motion-listener being removed |
Removes the old action-listener from action-listener-l and returns the resulting multicast listener.
l | action-listener-l |
---|---|
oldl | the action-listener being removed |
Removes the old window-focus-listener from window-focus-listener-l and returns the resulting multicast listener.
l | window-focus-listener-l |
---|---|
oldl | the window-focus-listener being removed |
Removes the old container-listener from container-listener-l and returns the resulting multicast listener.
l | container-listener-l |
---|---|
oldl | the container-listener being removed |
Removes the old item-listener from item-listener-l and returns the resulting multicast listener.
l | item-listener-l |
---|---|
oldl | the item-listener being removed |
Removes the old window-state-listener from window-state-listener-l and returns the resulting multicast listener.
l | window-state-listener-l |
---|---|
oldl | the window-state-listener being removed |
Removes the old focus-listener from focus-listener-l and returns the resulting multicast listener.
l | focus-listener-l |
---|---|
oldl | the focus-listener being removed |
Removes the old input-method-listener from input-method-listener-l and returns the resulting multicast listener.
l | input-method-listener-l |
---|---|
oldl | the input-method-listener being removed |
Removes the old mouse-wheel-listener from mouse-wheel-listener-l and returns the resulting multicast listener.
l | mouse-wheel-listener-l |
---|---|
oldl | the mouse-wheel-listener being removed |
Removes the old window-listener from window-listener-l and returns the resulting multicast listener.
l | window-listener-l |
---|---|
oldl | the window-listener being removed |
Removes the old adjustment-listener from adjustment-listener-l and returns the resulting multicast listener.
l | adjustment-listener-l |
---|---|
oldl | the adjustment-listener being removed |
Removes the old mouse-listener from mouse-listener-l and returns the resulting multicast listener.
l | mouse-listener-l |
---|---|
oldl | the mouse-listener being removed |
Removes the old key-listener from key-listener-l and returns the resulting multicast listener.
l | key-listener-l |
---|---|
oldl | the key-listener being removed |
Invoked when the value of the text has changed. The code written for this method performs the operations that need to occur when text changes.
Handles the windowActivated event by invoking the windowActivated methods on listener-a and listener-b.
e | the window event |
---|
Handles the windowClosed event by invoking the windowClosed methods on listener-a and listener-b.
e | the window event |
---|
Handles the windowClosing event by invoking the windowClosing methods on listener-a and listener-b.
e | the window event |
---|
Handles the windowDeactivated event by invoking the windowDeactivated methods on listener-a and listener-b.
e | the window event |
---|
Handles the windowDeiconfied event by invoking the windowDeiconified methods on listener-a and listener-b.
e | the window event |
---|
Handles the windowGainedFocus event by invoking the windowGainedFocus methods on listener-a and listener-b.
e | the window event |
---|
Handles the windowIconified event by invoking the windowIconified methods on listener-a and listener-b.
e | the window event |
---|
Handles the windowLostFocus event by invoking the windowLostFocus methods on listener-a and listener-b.
e | the window event |
---|
Handles the windowOpened event by invoking the windowOpened methods on listener-a and listener-b.
e | the window event |
---|
Handles the windowStateChanged event by invoking the windowStateChanged methods on listener-a and listener-b.
e | the window event |
---|
Returns the resulting multicast listener from adding listener-a and listener-b together. If listener-a is null, it returns listener-b; If listener-b is null, it returns listener-a If neither are null, then it creates and returns a new AWTEventMulticaster instance which chains a with b.
a | event listener-a |
---|---|
b | event listener-b |
Removes a listener from this multicaster.
The returned multicaster contains all the listeners in this
multicaster with the exception of all occurrences of oldl
.
If the resulting multicaster contains only one regular listener
the regular listener may be returned. If the resulting multicaster
is empty, then null
may be returned instead.
No exception is thrown if oldl
is null
.
oldl | the listener to be removed |
---|
Returns the resulting multicast listener after removing the old listener from listener-l. If listener-l equals the old listener OR listener-l is null, returns null. Else if listener-l is an instance of AWTEventMulticaster, then it removes the old listener from it. Else, returns listener l.
l | the listener being removed from |
---|---|
oldl | the listener being removed |