所有类


java.awt
类 AWTEventMulticaster

java.lang.Object
  继承者 java.awt.AWTEventMulticaster
所有已实现的接口:
ActionListener, AdjustmentListener, ComponentListener, ContainerListener, FocusListener, HierarchyBoundsListener, HierarchyListener, InputMethodListener, ItemListener, KeyListener, MouseListener, MouseMotionListener, MouseWheelListener, TextListener, WindowFocusListener, WindowListener, WindowStateListener, EventListener

public class AWTEventMulticaster
   
   
   
   
   
extends Object
implements ComponentListener, ContainerListener, FocusListener, KeyListener, MouseListener, MouseMotionListener, WindowListener, WindowFocusListener, WindowStateListener, ActionListener, ItemListener, AdjustmentListener, TextListener, InputMethodListener, HierarchyListener, HierarchyBoundsListener, MouseWheelListener

该类实现了对 java.awt.event 包中定义的 AWT 事件的指派,该指派是有效的、线程保护的多路广播事件指派。该类将管理一个由事件侦听器链组成的固定结构,并将为这些侦听器指派事件。由于结构是固定不变的,所以在事件指派操作过程中,可以使用这个 API 安全地添加/删除侦听器。不过,不会向目前正指派的事件通知事件指派操作过程中添加的事件侦听器。这是一个如何使用此类来实现一个可激发“操作”事件的新组件的例子:


 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());
         }
     }
 }
 

从以下版本开始:
1.1

字段摘要
protected  EventListenera
           
protected  EventListenerb
           
 
构造方法摘要
protected AWTEventMulticaster(EventListener a, EventListener b)
          创建一个将侦听器 a 和侦听器 b 链接起来的事件多路广播器实例。
 
方法摘要
 voidactionPerformed(ActionEvent e)
          通过在侦听器 a 和侦听器 b 上调用 actionPerformed 方法处理 actionPerformed 事件。
static ActionListeneradd(ActionListener a, ActionListener b)
          添加操作侦听器 a 和操作侦听器 b,并返回得到的多路广播侦听器。
static AdjustmentListeneradd(AdjustmentListener a, AdjustmentListener b)
          添加调整侦听器 a 和调整侦听器 b,并返回得到的多路广播侦听器。
static ComponentListeneradd(ComponentListener a, ComponentListener b)
          添加组件侦听器 a 和组件侦听器 b,并返回得到的多路广播侦听器。
static ContainerListeneradd(ContainerListener a, ContainerListener b)
          添加容器侦听器 a 和容器侦听器 b,并返回得到的多路广播侦听器。
static FocusListeneradd(FocusListener a, FocusListener b)
          添加焦点侦听器 a 和焦点侦听器 b,并返回得到的多路广播侦听器。
static HierarchyBoundsListeneradd(HierarchyBoundsListener a, HierarchyBoundsListener b)
          添加层次结构边界侦听器 a 和层次结构边界侦听器 b,并返回得到的多路广播侦听器。
static HierarchyListeneradd(HierarchyListener a, HierarchyListener b)
          添加层次结构侦听器 a 和层次结构侦听器 b,并返回得到的多路广播侦听器。
static InputMethodListeneradd(InputMethodListener a, InputMethodListener b)
          添加输入方法侦听器 a 和输入方法侦听器 b,并返回得到的多路广播侦听器。
static ItemListeneradd(ItemListener a, ItemListener b)
          添加项侦听器 a 和项侦听器 b,并返回得到的多路广播侦听器。
static KeyListeneradd(KeyListener a, KeyListener b)
          添加键侦听器 a 和键侦听器 b,并返回得到的多路广播侦听器。
static MouseListeneradd(MouseListener a, MouseListener b)
          添加鼠标侦听器 a 和鼠标侦听器 b,并返回得到的多路广播侦听器。
static MouseMotionListeneradd(MouseMotionListener a, MouseMotionListener b)
          添加鼠标移动侦听器 a 和鼠标移动侦听器 b,并返回得到的多路广播侦听器。
static MouseWheelListeneradd(MouseWheelListener a, MouseWheelListener b)
          添加鼠标滚轮侦听器 a 和鼠标滚轮侦听器 b,并返回得到的多路广播侦听器。
static TextListeneradd(TextListener a, TextListener b)
           
static WindowFocusListeneradd(WindowFocusListener a, WindowFocusListener b)
          添加窗口焦点侦听器 a 和窗口焦点侦听器 b,并返回得到的多路广播侦听器。
static WindowListeneradd(WindowListener a, WindowListener b)
          添加窗口侦听器 a 和窗口侦听器 b,并返回得到的多路广播侦听器。
static WindowStateListeneradd(WindowStateListener a, WindowStateListener b)
          添加窗口状态侦听器 a 和窗口状态侦听器 b,并返回得到的多路广播侦听器。
protected static EventListeneraddInternal(EventListener a, EventListener b)
          从正添加的侦听器 a 和侦听器 b 中一起返回得到的多路广播侦听器。
 voidadjustmentValueChanged(AdjustmentEvent e)
          通过在侦听器 a 和侦听器 b 上调用 adjustmentValueChanged 方法处理 adjustmentValueChanged 事件。
 voidancestorMoved(HierarchyEvent e)
          通过在侦听器 a 和侦听器 b 上调用 ancestorMoved 方法处理 ancestorMoved 事件。
 voidancestorResized(HierarchyEvent e)
          通过在侦听器 a 和侦听器 b 上调用 ancestorResized 方法处理 ancestorResized 事件。
 voidcaretPositionChanged(InputMethodEvent e)
          通过在侦听器 a 和侦听器 b 上调用 caretPositionChanged 方法处理 caretPositionChanged 事件。
 voidcomponentAdded(ContainerEvent e)
          通过在侦听器 a 和侦听器 b 上调用 componentAdded 方法处理 componentAdded 容器事件。
 voidcomponentHidden(ComponentEvent e)
          通过在侦听器 a 和侦听器 b 上调用 componentHidden 方法处理 componentHidden 事件。
 voidcomponentMoved(ComponentEvent e)
          通过在侦听器 a 和侦听器 b 上调用 componentMoved 方法处理 componentMoved 事件。
 voidcomponentRemoved(ContainerEvent e)
          通过在侦听器 a 和侦听器 b 上调用 componentRemoved 方法处理 componentRemoved 容器事件。
 voidcomponentResized(ComponentEvent e)
          通过在侦听器 a 和侦听器 b 上调用 componentResized 方法处理 componentResized 事件。
 voidcomponentShown(ComponentEvent e)
          通过在侦听器 a 和侦听器 b 上调用 componentShown 方法处理 componentShown 事件。
 voidfocusGained(FocusEvent e)
          通过在侦听器 a 和侦听器 b 上调用 focusGained 方法处理 focusGained 事件。
 voidfocusLost(FocusEvent e)
          通过在侦听器 a 和侦听器 b 上调用 focusLost 方法处理 focusLost 事件。
static
<T extends EventListener>
T[]
getListeners(EventListener l, Class<T> listenerType)
          返回通过指定的 java.util.EventListener 链接为 FooListener 的所有对象的数组。
 voidhierarchyChanged(HierarchyEvent e)
          通过在侦听器 a 和侦听器 b 上调用 hierarchyChanged 方法处理 hierarchyChanged 事件。
 voidinputMethodTextChanged(InputMethodEvent e)
          通过在侦听器 a 和侦听器 b 上调用 inputMethodTextChanged 方法处理 inputMethodTextChanged 事件。
 voiditemStateChanged(ItemEvent e)
          通过在侦听器 a 和侦听器 b 上调用 itemStateChanged 方法处理 itemStateChanged 事件。
 voidkeyPressed(KeyEvent e)
          通过在侦听器 a 和侦听器 b 上调用 keyPressed 方法处理 keyPressed 事件。
 voidkeyReleased(KeyEvent e)
          通过在侦听器 a 和侦听器 b 上调用 keyReleased 方法处理 keyReleased 事件。
 voidkeyTyped(KeyEvent e)
          通过在侦听器 a 和侦听器 b 上调用 keyTyped 方法处理 keyTyped 事件。
 voidmouseClicked(MouseEvent e)
          通过在侦听器 a 和侦听器 b 上调用 mouseClicked 方法处理 mouseClicked 事件。
 voidmouseDragged(MouseEvent e)
          通过在侦听器 a 和侦听器 b 上调用 mouseDragged 方法处理 mouseDragged 事件。
 voidmouseEntered(MouseEvent e)
          通过在侦听器 a 和侦听器 b 上调用 mouseEntered 方法处理 mouseEntered 事件。
 voidmouseExited(MouseEvent e)
          通过在侦听器 a 和侦听器 b 上调用 mouseExited 方法处理 mouseExited 事件。
 voidmouseMoved(MouseEvent e)
          通过在侦听器 a 和侦听器 b 上调用 mouseMoved 方法处理 mouseMoved 事件。
 voidmousePressed(MouseEvent e)
          通过在侦听器 a 和侦听器 b 上调用 mousePressed 方法处理 mousePressed 事件。
 voidmouseReleased(MouseEvent e)
          通过在侦听器 a 和侦听器 b 上调用 mouseReleased 方法处理 mouseReleased 事件。
 voidmouseWheelMoved(MouseWheelEvent e)
          通过在侦听器 a 和侦听器 b 上调用 mouseWheelMoved 方法处理 mouseWheelMoved 事件。
static ActionListenerremove(ActionListener l, ActionListener oldl)
          从操作侦听器 l 中移除旧的操作侦听器,并返回得到的多路广播侦听器。
static AdjustmentListenerremove(AdjustmentListener l, AdjustmentListener oldl)
          从调整侦听器 l 中移除旧的调整侦听器,并返回得到的多路广播侦听器。
static ComponentListenerremove(ComponentListener l, ComponentListener oldl)
          从组件侦听器 l 中移除旧的组件侦听器,并返回得到的多路广播侦听器。
static ContainerListenerremove(ContainerListener l, ContainerListener oldl)
          从容器侦听器 l 中移除旧的容器侦听器,并返回得到的多路广播侦听器。
protected  EventListenerremove(EventListener oldl)
          从此多路广播器中移除一个侦听器,并返回得到的多路广播侦听器。
static FocusListenerremove(FocusListener l, FocusListener oldl)
          从焦点侦听器 l 中移除旧的焦点侦听器,并返回得到的多路广播侦听器。
static HierarchyBoundsListenerremove(HierarchyBoundsListener l, HierarchyBoundsListener oldl)
          从层次结构边界侦听器 l 中移除旧的层次结构边界侦听器,并返回得到的多路广播侦听器。
static HierarchyListenerremove(HierarchyListener l, HierarchyListener oldl)
          从层次结构侦听器 l 中移除旧的层次结构侦听器,并返回得到的多路广播侦听器。
static InputMethodListenerremove(InputMethodListener l, InputMethodListener oldl)
          从输入方法侦听器 l 中移除旧的输入方法侦听器,并返回得到的多路广播侦听器。
static ItemListenerremove(ItemListener l, ItemListener oldl)
          从项侦听器 l 中移除旧的项侦听器,并返回得到的多路广播侦听器。
static KeyListenerremove(KeyListener l, KeyListener oldl)
          从键侦听器 l 中移除旧的键侦听器,并返回得到的多路广播侦听器。
static MouseListenerremove(MouseListener l, MouseListener oldl)
          从鼠标侦听器 l 中移除旧的鼠标侦听器,并返回得到的多路广播侦听器。
static MouseMotionListenerremove(MouseMotionListener l, MouseMotionListener oldl)
          从鼠标移动侦听器 l 中移除旧的鼠标移动侦听器,并返回得到的多路广播侦听器。
static MouseWheelListenerremove(MouseWheelListener l, MouseWheelListener oldl)
          从鼠标滚轮侦听器 l 中移除旧的鼠标滚轮侦听器,并返回得到的多路广播侦听器。
static TextListenerremove(TextListener l, TextListener oldl)
           
static WindowFocusListenerremove(WindowFocusListener l, WindowFocusListener oldl)
          从窗口焦点侦听器 l 中移除旧的窗口焦点侦听器,并返回得到的多路广播侦听器。
static WindowListenerremove(WindowListener l, WindowListener oldl)
          从窗口侦听器 l 中移除旧的窗口侦听器,并返回得到的多路广播侦听器。
static WindowStateListenerremove(WindowStateListener l, WindowStateListener oldl)
          从窗口状态侦听器 l 中移除旧的窗口状态侦听器,并返回得到的多路广播侦听器。
protected static EventListenerremoveInternal(EventListener l, EventListener oldl)
          在从侦听器 l 中移除旧的侦听器之后,返回得到的多路广播侦听器。
protected static voidsave(ObjectOutputStream s, String k, EventListener l)
           
protected  voidsaveInternal(ObjectOutputStream s, String k)
           
 voidtextValueChanged(TextEvent e)
          文本的值已改变时调用。
 voidwindowActivated(WindowEvent e)
          通过在侦听器 a 和侦听器 b 上调用 windowActivated 方法处理 windowActivated 事件。
 voidwindowClosed(WindowEvent e)
          通过在侦听器 a 和侦听器 b 上调用 windowClosed 方法处理 windowClosed 事件。
 voidwindowClosing(WindowEvent e)
          通过在侦听器 a 和侦听器 b 上调用 windowClosing 方法处理 windowClosing 事件。
 voidwindowDeactivated(WindowEvent e)
          通过在侦听器 a 和侦听器 b 上调用 windowDeactivated 方法处理 windowDeactivated 事件。
 voidwindowDeiconified(WindowEvent e)
          通过在侦听器 a 和侦听器 b 上调用 windowDeiconified 方法处理 windowDeiconified 事件。
 voidwindowGainedFocus(WindowEvent e)
          通过在侦听器 a 和侦听器 b 上调用 windowGainedFocus 方法处理 windowGainedFocus 事件。
 voidwindowIconified(WindowEvent e)
          通过在侦听器 a 和侦听器 b 上调用 windowIconified 方法处理 windowIconified 事件。
 voidwindowLostFocus(WindowEvent e)
          通过在侦听器 a 和侦听器 b 上调用 windowLostFocus 方法处理 windowLostFocus 事件。
 voidwindowOpened(WindowEvent e)
          通过在侦听器 a 和侦听器 b 上调用 windowOpened 方法处理 windowOpened 事件。
 voidwindowStateChanged(WindowEvent e)
          通过在侦听器 a 和侦听器 b 上调用 windowStateChanged 方法处理 windowStateChanged 事件。
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

a

protected final EventListener a

b

protected final EventListener b
构造方法详细信息

AWTEventMulticaster

protected AWTEventMulticaster(EventListener a,
                              EventListener b)
创建一个将侦听器 a 和侦听器 b 链接起来的事件多路广播器实例。输入参数 ab 不应为 null,尽管在选择是否在这种情况下抛出 NullPointerException 时,实现可能各不相同。

参数:
a - 侦听器 a
b - 侦听器 b
方法详细信息

remove

protected EventListener remove(EventListener oldl)
从此多路广播器中移除一个侦听器,并返回得到的多路广播侦听器。

参数:
oldl - 要移除的侦听器。

componentResized

public void componentResized(ComponentEvent e)
通过在侦听器 a 和侦听器 b 上调用 componentResized 方法处理 componentResized 事件。

指定者:
接口 ComponentListener 中的 componentResized
参数:
e - 组件事件

componentMoved

public void componentMoved(ComponentEvent e)
通过在侦听器 a 和侦听器 b 上调用 componentMoved 方法处理 componentMoved 事件。

指定者:
接口 ComponentListener 中的 componentMoved
参数:
e - 组件事件

componentShown

public void componentShown(ComponentEvent e)
通过在侦听器 a 和侦听器 b 上调用 componentShown 方法处理 componentShown 事件。

指定者:
接口 ComponentListener 中的 componentShown
参数:
e - 组件事件

componentHidden

public void componentHidden(ComponentEvent e)
通过在侦听器 a 和侦听器 b 上调用 componentHidden 方法处理 componentHidden 事件。

指定者:
接口 ComponentListener 中的 componentHidden
参数:
e - 组件事件

componentAdded

public void componentAdded(ContainerEvent e)
通过在侦听器 a 和侦听器 b 上调用 componentAdded 方法处理 componentAdded 容器事件。

指定者:
接口 ContainerListener 中的 componentAdded
参数:
e - 组件事件