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.
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.
(*add a b)
Adds component-listener-a with component-listener-b and returns the resulting multicast listener.
a - component-listener-a - java.awt.event.ComponentListener
b - component-listener-b - java.awt.event.ComponentListener
returns: java.awt.event.ComponentListener
Adds component-listener-a with component-listener-b and returns the resulting multicast listener. a - component-listener-a - `java.awt.event.ComponentListener` b - component-listener-b - `java.awt.event.ComponentListener` returns: `java.awt.event.ComponentListener`
(*get-listeners l listener-type)
Returns an array of all the objects chained as FooListeners by the specified java.util.EventListener. FooListeners 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 chained, this method returns an empty array.
l - the specified java.util.EventListener - java.util.EventListener
listener-type - the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener - java.lang.Class
returns: an array of all objects chained as
FooListeners by the specified multicast
listener, or an empty array if no such listeners have been
chained by the specified multicast listener - <T extends java.util.EventListener> T[]
throws: java.lang.NullPointerException - if the specified listenertype parameter is null
Returns an array of all the objects chained as FooListeners by the specified java.util.EventListener. FooListeners 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 chained, this method returns an empty array. l - the specified java.util.EventListener - `java.util.EventListener` listener-type - the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener - `java.lang.Class` returns: an array of all objects chained as FooListeners by the specified multicast listener, or an empty array if no such listeners have been chained by the specified multicast listener - `<T extends java.util.EventListener> T[]` throws: java.lang.NullPointerException - if the specified listenertype parameter is null
(*remove l oldl)
Removes the old component-listener from component-listener-l and returns the resulting multicast listener.
l - component-listener-l - java.awt.event.ComponentListener
oldl - the component-listener being removed - java.awt.event.ComponentListener
returns: java.awt.event.ComponentListener
Removes the old component-listener from component-listener-l and returns the resulting multicast listener. l - component-listener-l - `java.awt.event.ComponentListener` oldl - the component-listener being removed - `java.awt.event.ComponentListener` returns: `java.awt.event.ComponentListener`
(action-performed this e)
Handles the actionPerformed event by invoking the actionPerformed methods on listener-a and listener-b.
e - the action event - java.awt.event.ActionEvent
Handles the actionPerformed event by invoking the actionPerformed methods on listener-a and listener-b. e - the action event - `java.awt.event.ActionEvent`
(adjustment-value-changed this e)
Handles the adjustmentValueChanged event by invoking the adjustmentValueChanged methods on listener-a and listener-b.
e - the adjustment event - java.awt.event.AdjustmentEvent
Handles the adjustmentValueChanged event by invoking the adjustmentValueChanged methods on listener-a and listener-b. e - the adjustment event - `java.awt.event.AdjustmentEvent`
(ancestor-moved this e)
Handles the ancestorMoved event by invoking the ancestorMoved methods on listener-a and listener-b.
e - the item event - java.awt.event.HierarchyEvent
Handles the ancestorMoved event by invoking the ancestorMoved methods on listener-a and listener-b. e - the item event - `java.awt.event.HierarchyEvent`
(ancestor-resized this e)
Handles the ancestorResized event by invoking the ancestorResized methods on listener-a and listener-b.
e - the item event - java.awt.event.HierarchyEvent
Handles the ancestorResized event by invoking the ancestorResized methods on listener-a and listener-b. e - the item event - `java.awt.event.HierarchyEvent`
(caret-position-changed this e)
Handles the caretPositionChanged event by invoking the caretPositionChanged methods on listener-a and listener-b.
e - the item event - java.awt.event.InputMethodEvent
Handles the caretPositionChanged event by invoking the caretPositionChanged methods on listener-a and listener-b. e - the item event - `java.awt.event.InputMethodEvent`
(component-added this e)
Handles the componentAdded container event by invoking the componentAdded methods on listener-a and listener-b.
e - the component event - java.awt.event.ContainerEvent
Handles the componentAdded container event by invoking the componentAdded methods on listener-a and listener-b. e - the component event - `java.awt.event.ContainerEvent`
(component-hidden this e)
Handles the componentHidden event by invoking the componentHidden methods on listener-a and listener-b.
e - the component event - java.awt.event.ComponentEvent
Handles the componentHidden event by invoking the componentHidden methods on listener-a and listener-b. e - the component event - `java.awt.event.ComponentEvent`
(component-moved this e)
Handles the componentMoved event by invoking the componentMoved methods on listener-a and listener-b.
e - the component event - java.awt.event.ComponentEvent
Handles the componentMoved event by invoking the componentMoved methods on listener-a and listener-b. e - the component event - `java.awt.event.ComponentEvent`
(component-removed this e)
Handles the componentRemoved container event by invoking the componentRemoved methods on listener-a and listener-b.
e - the component event - java.awt.event.ContainerEvent
Handles the componentRemoved container event by invoking the componentRemoved methods on listener-a and listener-b. e - the component event - `java.awt.event.ContainerEvent`
(component-resized this e)
Handles the componentResized event by invoking the componentResized methods on listener-a and listener-b.
e - the component event - java.awt.event.ComponentEvent
Handles the componentResized event by invoking the componentResized methods on listener-a and listener-b. e - the component event - `java.awt.event.ComponentEvent`
(component-shown this e)
Handles the componentShown event by invoking the componentShown methods on listener-a and listener-b.
e - the component event - java.awt.event.ComponentEvent
Handles the componentShown event by invoking the componentShown methods on listener-a and listener-b. e - the component event - `java.awt.event.ComponentEvent`
(focus-gained this e)
Handles the focusGained event by invoking the focusGained methods on listener-a and listener-b.
e - the focus event - java.awt.event.FocusEvent
Handles the focusGained event by invoking the focusGained methods on listener-a and listener-b. e - the focus event - `java.awt.event.FocusEvent`
(focus-lost this e)
Handles the focusLost event by invoking the focusLost methods on listener-a and listener-b.
e - the focus event - java.awt.event.FocusEvent
Handles the focusLost event by invoking the focusLost methods on listener-a and listener-b. e - the focus event - `java.awt.event.FocusEvent`
(hierarchy-changed this e)
Handles the hierarchyChanged event by invoking the hierarchyChanged methods on listener-a and listener-b.
e - the item event - java.awt.event.HierarchyEvent
Handles the hierarchyChanged event by invoking the hierarchyChanged methods on listener-a and listener-b. e - the item event - `java.awt.event.HierarchyEvent`
(input-method-text-changed this e)
Handles the inputMethodTextChanged event by invoking the inputMethodTextChanged methods on listener-a and listener-b.
e - the item event - java.awt.event.InputMethodEvent
Handles the inputMethodTextChanged event by invoking the inputMethodTextChanged methods on listener-a and listener-b. e - the item event - `java.awt.event.InputMethodEvent`
(item-state-changed this e)
Handles the itemStateChanged event by invoking the itemStateChanged methods on listener-a and listener-b.
e - the item event - java.awt.event.ItemEvent
Handles the itemStateChanged event by invoking the itemStateChanged methods on listener-a and listener-b. e - the item event - `java.awt.event.ItemEvent`
(key-pressed this e)
Handles the keyPressed event by invoking the keyPressed methods on listener-a and listener-b.
e - the key event - java.awt.event.KeyEvent
Handles the keyPressed event by invoking the keyPressed methods on listener-a and listener-b. e - the key event - `java.awt.event.KeyEvent`
(key-released this e)
Handles the keyReleased event by invoking the keyReleased methods on listener-a and listener-b.
e - the key event - java.awt.event.KeyEvent
Handles the keyReleased event by invoking the keyReleased methods on listener-a and listener-b. e - the key event - `java.awt.event.KeyEvent`
(key-typed this e)
Handles the keyTyped event by invoking the keyTyped methods on listener-a and listener-b.
e - the key event - java.awt.event.KeyEvent
Handles the keyTyped event by invoking the keyTyped methods on listener-a and listener-b. e - the key event - `java.awt.event.KeyEvent`
(mouse-clicked this e)
Handles the mouseClicked event by invoking the mouseClicked methods on listener-a and listener-b.
e - the mouse event - java.awt.event.MouseEvent
Handles the mouseClicked event by invoking the mouseClicked methods on listener-a and listener-b. e - the mouse event - `java.awt.event.MouseEvent`
(mouse-dragged this e)
Handles the mouseDragged event by invoking the mouseDragged methods on listener-a and listener-b.
e - the mouse event - java.awt.event.MouseEvent
Handles the mouseDragged event by invoking the mouseDragged methods on listener-a and listener-b. e - the mouse event - `java.awt.event.MouseEvent`
(mouse-entered this e)
Handles the mouseEntered event by invoking the mouseEntered methods on listener-a and listener-b.
e - the mouse event - java.awt.event.MouseEvent
Handles the mouseEntered event by invoking the mouseEntered methods on listener-a and listener-b. e - the mouse event - `java.awt.event.MouseEvent`
(mouse-exited this e)
Handles the mouseExited event by invoking the mouseExited methods on listener-a and listener-b.
e - the mouse event - java.awt.event.MouseEvent
Handles the mouseExited event by invoking the mouseExited methods on listener-a and listener-b. e - the mouse event - `java.awt.event.MouseEvent`
(mouse-moved this e)
Handles the mouseMoved event by invoking the mouseMoved methods on listener-a and listener-b.
e - the mouse event - java.awt.event.MouseEvent
Handles the mouseMoved event by invoking the mouseMoved methods on listener-a and listener-b. e - the mouse event - `java.awt.event.MouseEvent`
(mouse-pressed this e)
Handles the mousePressed event by invoking the mousePressed methods on listener-a and listener-b.
e - the mouse event - java.awt.event.MouseEvent
Handles the mousePressed event by invoking the mousePressed methods on listener-a and listener-b. e - the mouse event - `java.awt.event.MouseEvent`
(mouse-released this e)
Handles the mouseReleased event by invoking the mouseReleased methods on listener-a and listener-b.
e - the mouse event - java.awt.event.MouseEvent
Handles the mouseReleased event by invoking the mouseReleased methods on listener-a and listener-b. e - the mouse event - `java.awt.event.MouseEvent`
(mouse-wheel-moved this e)
Handles the mouseWheelMoved event by invoking the mouseWheelMoved methods on listener-a and listener-b.
e - the mouse event - java.awt.event.MouseWheelEvent
Handles the mouseWheelMoved event by invoking the mouseWheelMoved methods on listener-a and listener-b. e - the mouse event - `java.awt.event.MouseWheelEvent`
(text-value-changed this e)
Description copied from interface: TextListener
e - java.awt.event.TextEvent
Description copied from interface: TextListener e - `java.awt.event.TextEvent`
(window-activated this e)
Handles the windowActivated event by invoking the windowActivated methods on listener-a and listener-b.
e - the window event - java.awt.event.WindowEvent
Handles the windowActivated event by invoking the windowActivated methods on listener-a and listener-b. e - the window event - `java.awt.event.WindowEvent`
(window-closed this e)
Handles the windowClosed event by invoking the windowClosed methods on listener-a and listener-b.
e - the window event - java.awt.event.WindowEvent
Handles the windowClosed event by invoking the windowClosed methods on listener-a and listener-b. e - the window event - `java.awt.event.WindowEvent`
(window-closing this e)
Handles the windowClosing event by invoking the windowClosing methods on listener-a and listener-b.
e - the window event - java.awt.event.WindowEvent
Handles the windowClosing event by invoking the windowClosing methods on listener-a and listener-b. e - the window event - `java.awt.event.WindowEvent`
(window-deactivated this e)
Handles the windowDeactivated event by invoking the windowDeactivated methods on listener-a and listener-b.
e - the window event - java.awt.event.WindowEvent
Handles the windowDeactivated event by invoking the windowDeactivated methods on listener-a and listener-b. e - the window event - `java.awt.event.WindowEvent`
(window-deiconified this e)
Handles the windowDeiconfied event by invoking the windowDeiconified methods on listener-a and listener-b.
e - the window event - java.awt.event.WindowEvent
Handles the windowDeiconfied event by invoking the windowDeiconified methods on listener-a and listener-b. e - the window event - `java.awt.event.WindowEvent`
(window-gained-focus this e)
Handles the windowGainedFocus event by invoking the windowGainedFocus methods on listener-a and listener-b.
e - the window event - java.awt.event.WindowEvent
Handles the windowGainedFocus event by invoking the windowGainedFocus methods on listener-a and listener-b. e - the window event - `java.awt.event.WindowEvent`
(window-iconified this e)
Handles the windowIconified event by invoking the windowIconified methods on listener-a and listener-b.
e - the window event - java.awt.event.WindowEvent
Handles the windowIconified event by invoking the windowIconified methods on listener-a and listener-b. e - the window event - `java.awt.event.WindowEvent`
(window-lost-focus this e)
Handles the windowLostFocus event by invoking the windowLostFocus methods on listener-a and listener-b.
e - the window event - java.awt.event.WindowEvent
Handles the windowLostFocus event by invoking the windowLostFocus methods on listener-a and listener-b. e - the window event - `java.awt.event.WindowEvent`
(window-opened this e)
Handles the windowOpened event by invoking the windowOpened methods on listener-a and listener-b.
e - the window event - java.awt.event.WindowEvent
Handles the windowOpened event by invoking the windowOpened methods on listener-a and listener-b. e - the window event - `java.awt.event.WindowEvent`
(window-state-changed this e)
Handles the windowStateChanged event by invoking the windowStateChanged methods on listener-a and listener-b.
e - the window event - java.awt.event.WindowEvent
Handles the windowStateChanged event by invoking the windowStateChanged methods on listener-a and listener-b. e - the window event - `java.awt.event.WindowEvent`
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close