java.lang.Object | +--java.awt.AWTEventMulticaster
Unsafe: 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 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
if (actionListener != null) {
actionListener.actionPerformed(new ActionEvent());
}
}
protected
AWTEventMulticaster(EventListener a,
EventListener b)
void
actionPerformed(ActionEvent e)
static ActionListener
add(ActionListener a,
ActionListener b)
static AdjustmentListener
add(AdjustmentListener a,
AdjustmentListener b)
static ComponentListener
add(ComponentListener a,
ComponentListener b)
static ContainerListener
add(ContainerListener a,
ContainerListener b)
static FocusListener
add(FocusListener a,
FocusListener b)
static HierarchyBoundsListener
add(HierarchyBoundsListener a,
HierarchyBoundsListener b)
static HierarchyListener
add(HierarchyListener a,
HierarchyListener b)
static InputMethodListener
add(InputMethodListener a,
InputMethodListener b)
static ItemListener
add(ItemListener a,
ItemListener b)
static KeyListener
add(KeyListener a,
KeyListener b)
static MouseListener
add(MouseListener a,
MouseListener b)
static MouseMotionListener
add(MouseMotionListener a,
MouseMotionListener b)
static MouseWheelListener
add(MouseWheelListener a,
MouseWheelListener b)
static WindowFocusListener
add(WindowFocusListener a,
WindowFocusListener b)
static WindowListener
add(WindowListener a,
WindowListener b)
static WindowStateListener
add(WindowStateListener a,
WindowStateListener b)
protected static EventListener
addInternal(EventListener a,
EventListener b)
void
adjustmentValueChanged(AdjustmentEvent e)
void
ancestorMoved(HierarchyEvent e)
void
ancestorResized(HierarchyEvent e)
void
caretPositionChanged(InputMethodEvent e)
void
componentAdded(ContainerEvent e)
void
componentHidden(ComponentEvent e)
void
componentMoved(ComponentEvent e)
void
componentRemoved(ContainerEvent e)
void
componentResized(ComponentEvent e)
void
componentShown(ComponentEvent e)
void
focusGained(FocusEvent e)
void
focusLost(FocusEvent e)
static EventListener[]
getListeners(EventListener l,
Class listenerType)
FooListener
s by the specified
java.util.EventListener
.
void
hierarchyChanged(HierarchyEvent e)
void
inputMethodTextChanged(InputMethodEvent e)
void
itemStateChanged(ItemEvent e)
void
keyPressed(KeyEvent e)
void
keyReleased(KeyEvent e)
void
keyTyped(KeyEvent e)
void
mouseClicked(MouseEvent e)
void
mouseDragged(MouseEvent e)
void
mouseEntered(MouseEvent e)
void
mouseExited(MouseEvent e)
void
mouseMoved(MouseEvent e)
void
mousePressed(MouseEvent e)
void
mouseReleased(MouseEvent e)
void
mouseWheelMoved(MouseWheelEvent e)
static ActionListener
remove(ActionListener l,
ActionListener oldl)
static AdjustmentListener
remove(AdjustmentListener l,
AdjustmentListener oldl)
static ComponentListener
remove(ComponentListener l,
ComponentListener oldl)
static ContainerListener
remove(ContainerListener l,
ContainerListener oldl)
protected EventListener
remove(EventListener oldl)
static FocusListener
remove(FocusListener l,
FocusListener oldl)
static HierarchyBoundsListener
remove(HierarchyBoundsListener l,
HierarchyBoundsListener oldl)
static HierarchyListener
remove(HierarchyListener l,
HierarchyListener oldl)
static InputMethodListener
remove(InputMethodListener l,
InputMethodListener oldl)
static ItemListener
remove(ItemListener l,
ItemListener oldl)
static KeyListener
remove(KeyListener l,
KeyListener oldl)
static MouseListener
remove(MouseListener l,
MouseListener oldl)
static MouseMotionListener
remove(MouseMotionListener l,
MouseMotionListener oldl)
static MouseWheelListener
remove(MouseWheelListener l,
MouseWheelListener oldl)
static WindowFocusListener
remove(WindowFocusListener l,
WindowFocusListener oldl)
static WindowListener
remove(WindowListener l,
WindowListener oldl)
static WindowStateListener
remove(WindowStateListener l,
WindowStateListener oldl)
protected static EventListener
removeInternal(EventListener l,
EventListener oldl)
void
windowActivated(WindowEvent e)
void
windowClosed(WindowEvent e)
void
windowClosing(WindowEvent e)
void
windowDeactivated(WindowEvent e)
void
windowDeiconified(WindowEvent e)
void
windowGainedFocus(WindowEvent e)
void
windowIconified(WindowEvent e)
void
windowLostFocus(WindowEvent e)
void
windowOpened(WindowEvent e)
void
windowStateChanged(WindowEvent e)
protected final EventListener a
protected final EventListener b
protected AWTEventMulticaster(EventListener a, EventListener b)
a
and b
should not be null
, though implementations may vary in
choosing whether or not to throw NullPointerException
in that case.
a
- listener-ab
- listener-bprotected EventListener remove(EventListener oldl)
oldl
- the listener to be removedpublic void componentResized(ComponentEvent e)
componentResized
in interface ComponentListener
e
- the component eventpublic void componentMoved(ComponentEvent e)
componentMoved
in interface ComponentListener
e
- the component eventpublic void componentShown(ComponentEvent e)
componentShown
in interface ComponentListener
e
- the component eventpublic void componentHidden(ComponentEvent e)
componentHidden
in interface ComponentListener
e
- the component eventpublic void componentAdded(ContainerEvent e)
componentAdded
in interface ContainerListener
e
- the component eventpublic void componentRemoved(ContainerEvent e)
componentRemoved
in interface ContainerListener
e
- the component eventpublic void focusGained(FocusEvent e)
focusGained
in interface FocusListener
e
- the focus eventpublic void focusLost(FocusEvent e)
focusLost
in interface FocusListener
e
- the focus eventpublic void keyTyped(KeyEvent e)
keyTyped
in interface KeyListener
e
- the key eventpublic void keyPressed(KeyEvent e)
keyPressed
in interface KeyListener
e
- the key eventpublic void keyReleased(KeyEvent e)
keyReleased
in interface KeyListener
e
- the key eventpublic void mouseClicked(MouseEvent e)
mouseClicked
in interface MouseListener
e
- the mouse eventpublic void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
e
- the mouse eventpublic void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
e
- the mouse eventpublic void mouseEntered(MouseEvent e)
mouseEntered
in interface MouseListener
e
- the mouse eventpublic void mouseExited(MouseEvent e)
mouseExited
in interface MouseListener
e
- the mouse eventpublic void mouseDragged(MouseEvent e)
mouseDragged
in interface MouseMotionListener
e
- the mouse eventpublic void mouseMoved(MouseEvent e)
mouseMoved
in interface MouseMotionListener
e
- the mouse eventpublic void windowOpened(WindowEvent e)
windowOpened
in interface WindowListener
e
- the window eventpublic void windowClosing(WindowEvent e)
windowClosing
in interface WindowListener
e
- the window eventpublic void windowClosed(WindowEvent e)
windowClosed
in interface WindowListener
e
- the window eventpublic void windowIconified(WindowEvent e)
windowIconified
in interface WindowListener
e
- the window eventjava.awt.Frame#setIconImage
public void windowDeiconified(WindowEvent e)
windowDeiconified
in interface WindowListener
e
- the window eventpublic void windowActivated(WindowEvent e)
windowActivated
in interface WindowListener
e
- the window eventpublic void windowDeactivated(WindowEvent e)
windowDeactivated
in interface WindowListener
e
- the window eventpublic void windowStateChanged(WindowEvent e)
windowStateChanged
in interface WindowStateListener
e
- the window eventpublic void windowGainedFocus(WindowEvent e)
windowGainedFocus
in interface WindowFocusListener
e
- the window eventpublic void windowLostFocus(WindowEvent e)
windowLostFocus
in interface WindowFocusListener
e
- the window eventpublic void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener
e
- the action eventpublic void itemStateChanged(ItemEvent e)
itemStateChanged
in interface ItemListener
e
- the item eventpublic void adjustmentValueChanged(AdjustmentEvent e)
adjustmentValueChanged
in interface AdjustmentListener
e
- the adjustment eventpublic void textValueChanged(TextEvent e)
textValueChanged
in interface TextListener
public void inputMethodTextChanged(InputMethodEvent e)
inputMethodTextChanged
in interface InputMethodListener
e
- the item eventpublic void caretPositionChanged(InputMethodEvent e)
caretPositionChanged
in interface InputMethodListener
e
- the item eventpublic void hierarchyChanged(HierarchyEvent e)
hierarchyChanged
in interface HierarchyListener
e
- the item eventHierarchyEvent.getChangeFlags()
public void ancestorMoved(HierarchyEvent e)
ancestorMoved
in interface HierarchyBoundsListener
e
- the item eventpublic void ancestorResized(HierarchyEvent e)
ancestorResized
in interface HierarchyBoundsListener
e
- the item eventpublic void mouseWheelMoved(MouseWheelEvent e)
mouseWheelMoved
in interface MouseWheelListener
e
- the mouse eventMouseWheelEvent
public static ComponentListener add(ComponentListener a, ComponentListener b)
a
- component-listener-ab
- component-listener-bpublic static ContainerListener add(ContainerListener a, ContainerListener b)
a
- container-listener-ab
- container-listener-bpublic static FocusListener add(FocusListener a, FocusListener b)
a
- focus-listener-ab
- focus-listener-bpublic static KeyListener add(KeyListener a, KeyListener b)
a
- key-listener-ab
- key-listener-bpublic static MouseListener add(MouseListener a, MouseListener b)
a
- mouse-listener-ab
- mouse-listener-bpublic static MouseMotionListener add(MouseMotionListener a, MouseMotionListener b)
a
- mouse-motion-listener-ab
- mouse-motion-listener-bpublic static WindowListener add(WindowListener a, WindowListener b)
a
- window-listener-ab
- window-listener-bpublic static WindowStateListener add(WindowStateListener a, WindowStateListener b)
a
- window-state-listener-ab
- window-state-listener-bpublic static WindowFocusListener add(WindowFocusListener a, WindowFocusListener b)
a
- window-focus-listener-ab
- window-focus-listener-bpublic static ActionListener add(ActionListener a, ActionListener b)
a
- action-listener-ab
- action-listener-bpublic static ItemListener add(ItemListener a, ItemListener b)
a
- item-listener-ab
- item-listener-bpublic static AdjustmentListener add(AdjustmentListener a, AdjustmentListener b)
a
- adjustment-listener-ab
- adjustment-listener-bpublic static TextListener add(TextListener a, TextListener b)
public static InputMethodListener add(InputMethodListener a, InputMethodListener b)
a
- input-method-listener-ab
- input-method-listener-bpublic static HierarchyListener add(HierarchyListener a, HierarchyListener b)
a
- hierarchy-listener-ab
- hierarchy-listener-bpublic static HierarchyBoundsListener add(HierarchyBoundsListener a, HierarchyBoundsListener b)
a
- hierarchy-bounds-listener-ab
- hierarchy-bounds-listener-bpublic static MouseWheelListener add(MouseWheelListener a, MouseWheelListener b)
a
- mouse-wheel-listener-ab
- mouse-wheel-listener-bpublic static ComponentListener remove(ComponentListener l, ComponentListener oldl)
l
- component-listener-loldl
- the component-listener being removedpublic static ContainerListener remove(ContainerListener l, ContainerListener oldl)
l
- container-listener-loldl
- the container-listener being removedpublic static FocusListener remove(FocusListener l, FocusListener oldl)
l
- focus-listener-loldl
- the focus-listener being removedpublic static KeyListener remove(KeyListener l, KeyListener oldl)
l
- key-listener-loldl
- the key-listener being removedpublic static MouseListener remove(MouseListener l, MouseListener oldl)
l
- mouse-listener-loldl
- the mouse-listener being removedpublic static MouseMotionListener remove(MouseMotionListener l, MouseMotionListener oldl)
l
- mouse-motion-listener-loldl
- the mouse-motion-listener being removedpublic static WindowListener remove(WindowListener l, WindowListener oldl)
l
- window-listener-loldl
- the window-listener being removedpublic static WindowStateListener remove(WindowStateListener l, WindowStateListener oldl)
l
- window-state-listener-loldl
- the window-state-listener being removedpublic static WindowFocusListener remove(WindowFocusListener l, WindowFocusListener oldl)
l
- window-focus-listener-loldl
- the window-focus-listener being removedpublic static ActionListener remove(ActionListener l, ActionListener oldl)
l
- action-listener-loldl
- the action-listener being removedpublic static ItemListener remove(ItemListener l, ItemListener oldl)
l
- item-listener-loldl
- the item-listener being removedpublic static AdjustmentListener remove(AdjustmentListener l, AdjustmentListener oldl)
l
- adjustment-listener-loldl
- the adjustment-listener being removedpublic static TextListener remove(TextListener l, TextListener oldl)
public static InputMethodListener remove(InputMethodListener l, InputMethodListener oldl)
l
- input-method-listener-loldl
- the input-method-listener being removedpublic static HierarchyListener remove(HierarchyListener l, HierarchyListener oldl)
l
- hierarchy-listener-loldl
- the hierarchy-listener being removedpublic static HierarchyBoundsListener remove(HierarchyBoundsListener l, HierarchyBoundsListener oldl)
l
- hierarchy-bounds-listener-loldl
- the hierarchy-bounds-listener being removedpublic static MouseWheelListener remove(MouseWheelListener l, MouseWheelListener oldl)
l
- mouse-wheel-listener-loldl
- the mouse-wheel-listener being removedprotected static EventListener addInternal(EventListener a, EventListener b)
a
- event listener-ab
- event listener-bprotected static EventListener removeInternal(EventListener l, EventListener oldl)
l
- the listener being removed fromoldl
- the listener being removedprotected void saveInternal(ObjectOutputStream s, String k) throws IOException
protected static void save(ObjectOutputStream s, String k, EventListener l) throws IOException
private static int getListenerCount(EventListener l, Class listenerType)
private static int populateListenerArray(EventListener[] a, EventListener l, int index)
public static EventListener[] getListeners(EventListener l, Class listenerType)
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 listener