java.awt
public class AWTEventMulticaster extends Object implements ComponentListener, ContainerListener, FocusListener, KeyListener, MouseListener, MouseMotionListener, WindowListener, WindowFocusListener, WindowStateListener, ActionListener, ItemListener, AdjustmentListener, TextListener, InputMethodListener, HierarchyListener, HierarchyBoundsListener, MouseWheelListener
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.
Since: 1.1
UNKNOWN: updated to 1.4
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 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 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 WindowListener | add(WindowListener a, WindowListener b)
Chain WindowListener a and b.
|
static WindowStateListener | add(WindowStateListener a, WindowStateListener b)
Chain WindowStateListener a and b.
|
static WindowFocusListener | add(WindowFocusListener a, WindowFocusListener b)
Chain WindowFocusListener a and b.
|
static ActionListener | add(ActionListener a, ActionListener b)
Chain ActionListener a and b.
|
static ItemListener | add(ItemListener a, ItemListener b)
Chain ItemListener a and b.
|
static AdjustmentListener | add(AdjustmentListener a, AdjustmentListener b)
Chain AdjustmentListener a and b.
|
static TextListener | add(TextListener a, TextListener b)
Chain AdjustmentListener a and b.
|
static InputMethodListener | add(InputMethodListener a, InputMethodListener b)
Chain InputMethodListener a and b.
|
static HierarchyListener | add(HierarchyListener a, HierarchyListener b)
Chain HierarchyListener a and b.
|
static HierarchyBoundsListener | add(HierarchyBoundsListener a, HierarchyBoundsListener b)
Chain HierarchyBoundsListener a and b.
|
static MouseWheelListener | add(MouseWheelListener a, MouseWheelListener b)
Chain MouseWheelListener 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 <T extends EventListener> T[] | 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.
|
protected EventListener | remove(EventListener oldl)
Removes one instance of the specified listener from this multicaster
chain. |
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 .
|
static FocusListener | remove(FocusListener l, FocusListener 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 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 .
|
static WindowFocusListener | remove(WindowFocusListener l, WindowFocusListener oldl)
Removes the listener oldl from the listener l .
|
static ActionListener | remove(ActionListener l, ActionListener 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 AdjustmentListener | remove(AdjustmentListener l, AdjustmentListener 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 InputMethodListener | remove(InputMethodListener l, InputMethodListener 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 HierarchyBoundsListener | remove(HierarchyBoundsListener l, HierarchyBoundsListener oldl)
Removes the listener oldl from the listener l .
|
static MouseWheelListener | remove(MouseWheelListener l, MouseWheelListener 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.
|
AWTEventMulticaster
with
the specified event listener parameters. The parameters should not be
null, although it is not required to enforce this with a
NullPointerException.
Parameters: a the "a" listener object b the "b" listener object
Parameters: e the event to handle
ComponentListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
ContainerListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
FocusListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
KeyListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
MouseListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
MouseMotionListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
WindowListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
WindowStateListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
Since: 1.4
WindowFocusListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
Since: 1.4
ActionListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
ItemListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
AdjustmentListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
AdjustmentListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
InputMethodListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
Since: 1.2
HierarchyListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
Since: 1.3
HierarchyBoundsListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
Since: 1.3
MouseWheelListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
Since: 1.4
EventListener
a and b.
Parameters: a the "a" listener, may be null b the "b" listener, may be null
Returns: latest entry in the chain
Parameters: e the event to handle
Parameters: e the event to handle
Since: 1.3
Parameters: e the event to handle
Since: 1.3
Parameters: e the event to handle
Since: 1.2
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: l the listener chain to convert to an array type the type of listeners to collect
Returns: an array of the listeners of that type in the chain
Throws: ClassCastException if type is not assignable from EventListener NullPointerException if type is null IllegalArgumentException if type is Void.TYPE
Since: 1.4
Parameters: e the event to handle
Since: 1.3
Parameters: e the event to handle
Since: 1.2
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Since: 1.4
Parameters: oldl the object to remove from this multicaster
Returns: the resulting multicaster with the specified listener removed
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
Since: 1.4
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
Since: 1.4
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
Since: 1.2
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
Since: 1.3
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
Since: 1.3
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
Since: 1.4
oldl
from the listener l
.
Parameters: l the listener chain to reduce oldl the listener to remove
Returns: the resulting listener chain
Parameters: s the stream to save to k a prefix stream put before each serializable listener l the listener chain to save
Throws: IOException if serialization fails
Parameters: s the stream to save to k a prefix stream put before each serializable listener
Throws: IOException if serialization fails
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Parameters: e the event to handle
Since: 1.4
Parameters: e the event to handle
Parameters: e the event to handle
Since: 1.4
Parameters: e the event to handle
Parameters: e the event to handle
Since: 1.4