|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.AWTEventMulticaster
public class AWTEventMulticaster
This class is used to implement a chain of event handlers. Dispatching
using this class is thread safe. Here is a quick example of how to
add and delete listeners using this class. For this example, we will
assume are firing AdjustmentEvent's. However, this
same approach is useful for all events in the java.awt.event
package, and more if this class is subclassed.
AdjustmentListener al;
public void addAdjustmentListener(AdjustmentListener listener)
{
al = AWTEventMulticaster.add(al, listener);
}
public void removeAdjustmentListener(AdjustmentListener listener)
{
al = AWTEventMulticaster.remove(al, listener);
}
When it come time to process an event, simply call al,
assuming it is not null, and all listeners in the chain will
be fired.
The first time add is called it is passed
null and listener as its arguments. This
starts building the chain. This class returns listener
which becomes the new al. The next time, add
is called with al and listener and the
new listener is then chained to the old.
| Field Summary | |
|---|---|
protected EventListener |
a
A variable in the event chain. |
protected EventListener |
b
A variable in the event chain. |
| Constructor Summary | |
|---|---|
protected |
AWTEventMulticaster(EventListener a,
EventListener b)
Initializes a new instance of AWTEventMulticaster with
the specified event listener parameters. |
| Method Summary | ||
|---|---|---|
void |
actionPerformed(ActionEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
static ActionListener |
add(ActionListener a,
ActionListener b)
Chain ActionListener a and b. |
|
static AdjustmentListener |
add(AdjustmentListener a,
AdjustmentListener b)
Chain AdjustmentListener a and b. |
|
static ComponentListener |
add(ComponentListener a,
ComponentListener b)
Chain ComponentListener a and b. |
|
static ContainerListener |
add(ContainerListener a,
ContainerListener b)
Chain ContainerListener a and b. |
|
static FocusListener |
add(FocusListener a,
FocusListener b)
Chain FocusListener a and b. |
|
static HierarchyBoundsListener |
add(HierarchyBoundsListener a,
HierarchyBoundsListener b)
Chain HierarchyBoundsListener a and b. |
|
static HierarchyListener |
add(HierarchyListener a,
HierarchyListener b)
Chain HierarchyListener a and b. |
|
static InputMethodListener |
add(InputMethodListener a,
InputMethodListener b)
Chain InputMethodListener a and b. |
|
static ItemListener |
add(ItemListener a,
ItemListener b)
Chain ItemListener a and b. |
|
static KeyListener |
add(KeyListener a,
KeyListener b)
Chain KeyListener a and b. |
|
static MouseListener |
add(MouseListener a,
MouseListener b)
Chain MouseListener a and b. |
|
static MouseMotionListener |
add(MouseMotionListener a,
MouseMotionListener b)
Chain MouseMotionListener a and b. |
|
static MouseWheelListener |
add(MouseWheelListener a,
MouseWheelListener b)
Chain MouseWheelListener a and b. |
|
static TextListener |
add(TextListener a,
TextListener b)
Chain AdjustmentListener a and b. |
|
static WindowFocusListener |
add(WindowFocusListener a,
WindowFocusListener b)
Chain WindowFocusListener a and b. |
|
static WindowListener |
add(WindowListener a,
WindowListener b)
Chain WindowListener a and b. |
|
static WindowStateListener |
add(WindowStateListener a,
WindowStateListener b)
Chain WindowStateListener a and b. |
|
protected static EventListener |
addInternal(EventListener a,
EventListener b)
Chain EventListener a and b. |
|
void |
adjustmentValueChanged(AdjustmentEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
ancestorMoved(HierarchyEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
ancestorResized(HierarchyEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
caretPositionChanged(InputMethodEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
componentAdded(ContainerEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
componentHidden(ComponentEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
componentMoved(ComponentEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
componentRemoved(ContainerEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
componentResized(ComponentEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
componentShown(ComponentEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
focusGained(FocusEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
focusLost(FocusEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
static
|
getListeners(EventListener l,
Class<T> type)
Returns an array of all chained listeners of the specified type in the given chain. |
|
void |
hierarchyChanged(HierarchyEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
inputMethodTextChanged(InputMethodEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
itemStateChanged(ItemEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
keyPressed(KeyEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
keyReleased(KeyEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
keyTyped(KeyEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
mouseClicked(MouseEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
mouseDragged(MouseEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
mouseEntered(MouseEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
mouseExited(MouseEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
mouseMoved(MouseEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
mousePressed(MouseEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
mouseReleased(MouseEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
mouseWheelMoved(MouseWheelEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
static ActionListener |
remove(ActionListener l,
ActionListener oldl)
Removes the listener oldl from the listener l. |
|
static AdjustmentListener |
remove(AdjustmentListener l,
AdjustmentListener oldl)
Removes the listener oldl from the listener l. |
|
static ComponentListener |
remove(ComponentListener l,
ComponentListener oldl)
Removes the listener oldl from the listener l. |
|
static ContainerListener |
remove(ContainerListener l,
ContainerListener oldl)
Removes the listener oldl from the listener l. |
|
protected EventListener |
remove(EventListener oldl)
Removes one instance of the specified listener from this multicaster chain. |
|
static FocusListener |
remove(FocusListener l,
FocusListener oldl)
Removes the listener oldl from the listener l. |
|
static HierarchyBoundsListener |
remove(HierarchyBoundsListener l,
HierarchyBoundsListener oldl)
Removes the listener oldl from the listener l. |
|
static HierarchyListener |
remove(HierarchyListener l,
HierarchyListener oldl)
Removes the listener oldl from the listener l. |
|
static InputMethodListener |
remove(InputMethodListener l,
InputMethodListener oldl)
Removes the listener oldl from the listener l. |
|
static ItemListener |
remove(ItemListener l,
ItemListener oldl)
Removes the listener oldl from the listener l. |
|
static KeyListener |
remove(KeyListener l,
KeyListener oldl)
Removes the listener oldl from the listener l. |
|
static MouseListener |
remove(MouseListener l,
MouseListener oldl)
Removes the listener oldl from the listener l. |
|
static MouseMotionListener |
remove(MouseMotionListener l,
MouseMotionListener oldl)
Removes the listener oldl from the listener l. |
|
static MouseWheelListener |
remove(MouseWheelListener l,
MouseWheelListener oldl)
Removes the listener oldl from the listener l. |
|
static TextListener |
remove(TextListener l,
TextListener oldl)
Removes the listener oldl from the listener l. |
|
static WindowFocusListener |
remove(WindowFocusListener l,
WindowFocusListener oldl)
Removes the listener oldl from the listener l. |
|
static WindowListener |
remove(WindowListener l,
WindowListener oldl)
Removes the listener oldl from the listener l. |
|
static WindowStateListener |
remove(WindowStateListener l,
WindowStateListener oldl)
Removes the listener oldl from the listener l. |
|
protected static EventListener |
removeInternal(EventListener l,
EventListener oldl)
Removes the listener oldl from the listener l. |
|
protected static void |
save(ObjectOutputStream s,
String k,
EventListener l)
Saves a Serializable listener chain to a serialization stream. |
|
protected void |
saveInternal(ObjectOutputStream s,
String k)
Saves all Serializable listeners to a serialization stream. |
|
void |
textValueChanged(TextEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
windowActivated(WindowEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
windowClosed(WindowEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
windowClosing(WindowEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
windowDeactivated(WindowEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
windowDeiconified(WindowEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
windowGainedFocus(WindowEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
windowIconified(WindowEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
windowLostFocus(WindowEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
windowOpened(WindowEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
void |
windowStateChanged(WindowEvent e)
Handles this event by dispatching it to the "a" and "b" listener instances. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final EventListener a
protected final EventListener b
| Constructor Detail |
|---|
protected AWTEventMulticaster(EventListener a,
EventListener b)
AWTEventMulticaster with
the specified event listener parameters. The parameters should not be
null, although it is not required to enforce this with a
NullPointerException.
a - the "a" listener objectb - the "b" listener object| Method Detail |
|---|
protected EventListener remove(EventListener oldl)
oldl - the object to remove from this multicaster
public void componentResized(ComponentEvent e)
componentResized in interface ComponentListenere - the event to handlepublic void componentMoved(ComponentEvent e)
componentMoved in interface ComponentListenere - the event to handlepublic void componentShown(ComponentEvent e)
componentShown in interface ComponentListenere - the event to handlepublic void componentHidden(ComponentEvent e)
componentHidden in interface ComponentListenere - the event to handlepublic void componentAdded(ContainerEvent e)
componentAdded in interface ContainerListenere - the event to handlepublic void componentRemoved(ContainerEvent e)
componentRemoved in interface ContainerListenere - the event to handlepublic void focusGained(FocusEvent e)
focusGained in interface FocusListenere - the event to handlepublic void focusLost(FocusEvent e)
focusLost in interface FocusListenere - the event to handlepublic void keyTyped(KeyEvent e)
keyTyped in interface KeyListenere - the event to handlepublic void keyPressed(KeyEvent e)
keyPressed in interface KeyListenere - the event to handlepublic void keyReleased(KeyEvent e)
keyReleased in interface KeyListenere - the event to handlepublic void mouseClicked(MouseEvent e)
mouseClicked in interface MouseListenere - the event to handlepublic void mousePressed(MouseEvent e)
mousePressed in interface MouseListenere - the event to handlepublic void mouseReleased(MouseEvent e)
mouseReleased in interface MouseListenere - the event to handlepublic void mouseEntered(MouseEvent e)
mouseEntered in interface MouseListenere - the event to handlepublic void mouseExited(MouseEvent e)
mouseExited in interface MouseListenere - the event to handlepublic void mouseDragged(MouseEvent e)
mouseDragged in interface MouseMotionListenere - the event to handlepublic void mouseMoved(MouseEvent e)
mouseMoved in interface MouseMotionListenere - the event to handlepublic void windowOpened(WindowEvent e)
windowOpened in interface WindowListenere - the event to handlepublic void windowClosing(WindowEvent e)
windowClosing in interface WindowListenere - the event to handlepublic void windowClosed(WindowEvent e)
windowClosed in interface WindowListenere - the event to handlepublic void windowIconified(WindowEvent e)
windowIconified in interface WindowListenere - the event to handleFrame.setIconImage(Image)public void windowDeiconified(WindowEvent e)
windowDeiconified in interface WindowListenere - the event to handlepublic void windowActivated(WindowEvent e)
windowActivated in interface WindowListenere - the event to handlepublic void windowDeactivated(WindowEvent e)
windowDeactivated in interface WindowListenere - the event to handlepublic void windowStateChanged(WindowEvent e)
windowStateChanged in interface WindowStateListenere - the event to handlepublic void windowGainedFocus(WindowEvent e)
windowGainedFocus in interface WindowFocusListenere - the event to handlepublic void windowLostFocus(WindowEvent e)
windowLostFocus in interface WindowFocusListenere - the event to handlepublic void actionPerformed(ActionEvent e)
actionPerformed in interface ActionListenere - the event to handlepublic void itemStateChanged(ItemEvent e)
itemStateChanged in interface ItemListenere - the event to handlepublic void adjustmentValueChanged(AdjustmentEvent e)
adjustmentValueChanged in interface AdjustmentListenere - the event to handlepublic void textValueChanged(TextEvent e)
textValueChanged in interface TextListenere - the event to handlepublic void inputMethodTextChanged(InputMethodEvent e)
inputMethodTextChanged in interface InputMethodListenere - the event to handlepublic void caretPositionChanged(InputMethodEvent e)
caretPositionChanged in interface InputMethodListenere - the event to handlepublic void hierarchyChanged(HierarchyEvent e)
hierarchyChanged in interface HierarchyListenere - the event to handlepublic void ancestorMoved(HierarchyEvent e)
ancestorMoved in interface HierarchyBoundsListenere - the event to handlepublic void ancestorResized(HierarchyEvent e)
ancestorResized in interface HierarchyBoundsListenere - the event to handlepublic void mouseWheelMoved(MouseWheelEvent e)
mouseWheelMoved in interface MouseWheelListenere - the event to handle
public static ComponentListener add(ComponentListener a,
ComponentListener b)
ComponentListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
public static ContainerListener add(ContainerListener a,
ContainerListener b)
ContainerListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
public static FocusListener add(FocusListener a,
FocusListener b)
FocusListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
public static KeyListener add(KeyListener a,
KeyListener b)
KeyListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
public static MouseListener add(MouseListener a,
MouseListener b)
MouseListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
public static MouseMotionListener add(MouseMotionListener a,
MouseMotionListener b)
MouseMotionListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
public static WindowListener add(WindowListener a,
WindowListener b)
WindowListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
public static WindowStateListener add(WindowStateListener a,
WindowStateListener b)
WindowStateListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
public static WindowFocusListener add(WindowFocusListener a,
WindowFocusListener b)
WindowFocusListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
public static ActionListener add(ActionListener a,
ActionListener b)
ActionListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
public static ItemListener add(ItemListener a,
ItemListener b)
ItemListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
public static AdjustmentListener add(AdjustmentListener a,
AdjustmentListener b)
AdjustmentListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
public static TextListener add(TextListener a,
TextListener b)
AdjustmentListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
public static InputMethodListener add(InputMethodListener a,
InputMethodListener b)
InputMethodListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
public static HierarchyListener add(HierarchyListener a,
HierarchyListener b)
HierarchyListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
public static HierarchyBoundsListener add(HierarchyBoundsListener a,
HierarchyBoundsListener b)
HierarchyBoundsListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
public static MouseWheelListener add(MouseWheelListener a,
MouseWheelListener b)
MouseWheelListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
public static ComponentListener remove(ComponentListener l,
ComponentListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
public static ContainerListener remove(ContainerListener l,
ContainerListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
public static FocusListener remove(FocusListener l,
FocusListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
public static KeyListener remove(KeyListener l,
KeyListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
public static MouseListener remove(MouseListener l,
MouseListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
public static MouseMotionListener remove(MouseMotionListener l,
MouseMotionListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
public static WindowListener remove(WindowListener l,
WindowListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
public static WindowStateListener remove(WindowStateListener l,
WindowStateListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
public static WindowFocusListener remove(WindowFocusListener l,
WindowFocusListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
public static ActionListener remove(ActionListener l,
ActionListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
public static ItemListener remove(ItemListener l,
ItemListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
public static AdjustmentListener remove(AdjustmentListener l,
AdjustmentListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
public static TextListener remove(TextListener l,
TextListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
public static InputMethodListener remove(InputMethodListener l,
InputMethodListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
public static HierarchyListener remove(HierarchyListener l,
HierarchyListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
public static HierarchyBoundsListener remove(HierarchyBoundsListener l,
HierarchyBoundsListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
public static MouseWheelListener remove(MouseWheelListener l,
MouseWheelListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
protected static EventListener addInternal(EventListener a,
EventListener b)
EventListener a and b.
a - the "a" listener, may be nullb - the "b" listener, may be null
protected static EventListener removeInternal(EventListener l,
EventListener oldl)
oldl from the listener l.
l - the listener chain to reduceoldl - the listener to remove
protected void saveInternal(ObjectOutputStream s,
String k)
throws IOException
s - the stream to save tok - a prefix stream put before each serializable listener
IOException - if serialization fails
protected static void save(ObjectOutputStream s,
String k,
EventListener l)
throws IOException
s - the stream to save tok - a prefix stream put before each serializable listenerl - the listener chain to save
IOException - if serialization fails
public static <T extends EventListener> T[] getListeners(EventListener l,
Class<T> type)
l - the listener chain to convert to an arraytype - the type of listeners to collect
ClassCastException - if type is not assignable from EventListener
NullPointerException - if type is null
IllegalArgumentException - if type is Void.TYPE
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||