http://download.java.net/jdk/jdk-api-localizations/jdk-api-zh-cn/publish/1.6.0/html/zh_CN/api/java/awt/AWTEventMulticaster.html
| JavaTM Platform Standard Ed. 6 | |||||||||
上一个类 下一个类 | 框架 无框架 <script type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../allclasses-noframe.html"><B>所有类</B></A>'); } //--> </script> 所有类 <noscript> <A HREF="../../allclasses-noframe.html"><B>所有类</B></A> </noscript> | |||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |
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 AWTEventMulticasterextends Object implements ComponentListener , ContainerListener , FocusListener , KeyListener , MouseListener , MouseMotionListener , WindowListener , WindowFocusListener , WindowStateListener , ActionListener , ItemListener , AdjustmentListener , TextListener , InputMethodListener , HierarchyListener , HierarchyBoundsListener , MouseWheelListener
AWTEventMulticaster
实现对 java.awt.event
包中定义的 AWT 事件的指派,该指派是有效的、线程安全的多路广播事件指派。
以下实例阐释了如何使用此类:
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());
}
}
}
需要重点注意的是 add
和 remove
方法的第一个参数,它是维护侦听器的字段。此外,必须将 add
和 remove
方法的结果分配给维护侦听器的字段。
AWTEventMulticaster
是作为一对 EventListeners
实现的,它们在构造时被设置。AWTEventMulticaster
是不可变的。add
和 remove
方法不得以任何方式改变 AWTEventMulticaster
。如有必要,可以创建一个新的 AWTEventMulticaster
。以这种方式在指派事件的过程中添加和移除侦听器是安全的。但是,不会向目前正指派的事件通知事件指派操作过程中添加的事件侦听器。
允许所有 add
方法使用 null
参数。如果第一个参数是 null
,则返回第二个参数。如果第一个参数不是 null
,而第二个参数是 null
,则返回第一个参数。如果两个参数都是 non-null
,则使用这两个参数创建一个新的 AWTEventMulticaster
并返回它。
对于使用两个参数的 remove
方法,返回以下内容:
null
,如果第一个参数是null
,或者参数相等(==
)。- 第一个参数,如果第一个参数不是一个
AWTEventMulticaster
实例。 - 在将第二个参数提供给
remove(EventListener)
方法的情况下,对第一个参数调用remove(EventListener)
的结果。
Swing 基于类似的逻辑使用 EventListenerList
。有关细节,请参见 EventListenerList
。
-
从以下版本开始:
- 1.1 另请参见:
-
EventListenerList
字段摘要 | |
---|---|
protected EventListener | a |
protected EventListener | b |
构造方法摘要 | |
---|---|
protected | AWTEventMulticaster (EventListener a, EventListener b) 创建一个将侦听器 a 和侦听器 b 链接起来的事件多路广播器实例。 |
方法摘要 | ||
---|---|---|
void | actionPerformed (ActionEvent e) 通过在侦听器 a 和侦听器 b 上调用 actionPerformed 方法处理 actionPerformed 事件。 | |
static ActionListener | add (ActionListener a, ActionListener b) 添加操作侦听器 a 和操作侦听器 b,并返回得到的多路广播侦听器。 | |
static AdjustmentListener | add (AdjustmentListener a, AdjustmentListener b) 添加调整侦听器 a 和调整侦听器 b,并返回得到的多路广播侦听器。 | |
static ComponentListener | add (ComponentListener a, ComponentListener b) 添加组件侦听器 a 和组件侦听器 b,并返回得到的多路广播侦听器。 | |
static ContainerListener | add (ContainerListener a, ContainerListener b) 添加容器侦听器 a 和容器侦听器 b,并返回得到的多路广播侦听器。 | |
static FocusListener | add (FocusListener a, FocusListener b) 添加焦点侦听器 a 和焦点侦听器 b,并返回得到的多路广播侦听器。 | |
static HierarchyBoundsListener | add (HierarchyBoundsListener a, HierarchyBoundsListener b) 添加层次结构边界侦听器 a 和层次结构边界侦听器 b,并返回得到的多路广播侦听器。 | |
static HierarchyListener | add (HierarchyListener a, HierarchyListener b) 添加层次结构侦听器 a 和层次结构侦听器 b,并返回得到的多路广播侦听器。 | |
static InputMethodListener | add (InputMethodListener a, InputMethodListener b) 添加输入方法侦听器 a 和输入方法侦听器 b,并返回得到的多路广播侦听器。 | |
static ItemListener | add (ItemListener a, ItemListener b) 添加项侦听器 a 和项侦听器 b,并返回得到的多路广播侦听器。 | |
static KeyListener | add (KeyListener a, KeyListener b) 添加键侦听器 a 和键侦听器 b,并返回得到的多路广播侦听器。 | |
static MouseListener | add (MouseListener a, MouseListener b) 添加鼠标侦听器 a 和鼠标侦听器 b,并返回得到的多路广播侦听器。 | |
static MouseMotionListener | add (MouseMotionListener a, MouseMotionListener b) 添加鼠标移动侦听器 a 和鼠标移动侦听器 b,并返回得到的多路广播侦听器。 | |
static MouseWheelListener | add (MouseWheelListener a, MouseWheelListener b) 添加鼠标滚轮侦听器 a 和鼠标滚轮侦听器 b,并返回得到的多路广播侦听器。 | |
static TextListener | add (TextListener a, TextListener b) | |
static WindowFocusListener | add (WindowFocusListener a, WindowFocusListener b) 添加窗口焦点侦听器 a 和窗口焦点侦听器 b,并返回得到的多路广播侦听器。 | |
static WindowListener | add (WindowListener a, WindowListener b) 添加窗口侦听器 a 和窗口侦听器 b,并返回得到的多路广播侦听器。 | |
static WindowStateListener | add (WindowStateListener a, WindowStateListener b) 添加窗口状态侦听器 a 和窗口状态侦听器 b,并返回得到的多路广播侦听器。 | |
protected static EventListener | addInternal (EventListener a, EventListener b) 从正添加的侦听器 a 和侦听器 b 中一起返回得到的多路广播侦听器。 | |
void | adjustmentValueChanged (AdjustmentEvent e) 通过在侦听器 a 和侦听器 b 上调用 adjustmentValueChanged 方法处理 adjustmentValueChanged 事件。 | |
void | ancestorMoved (HierarchyEvent e) 通过在侦听器 a 和侦听器 b 上调用 ancestorMoved 方法处理 ancestorMoved 事件。 | |
void | ancestorResized (HierarchyEvent e) 通过在侦听器 a 和侦听器 b 上调用 ancestorResized 方法处理 ancestorResized 事件。 | |
void | caretPositionChanged (InputMethodEvent e) 通过在侦听器 a 和侦听器 b 上调用 caretPositionChanged 方法处理 caretPositionChanged 事件。 | |
void | componentAdded (ContainerEvent e) 通过在侦听器 a 和侦听器 b 上调用 componentAdded 方法处理 componentAdded 容器事件。 | |
void | componentHidden (ComponentEvent e) 通过在侦听器 a 和侦听器 b 上调用 componentHidden 方法处理 componentHidden 事件。 | |
void | componentMoved (ComponentEvent e) 通过在侦听器 a 和侦听器 b 上调用 componentMoved 方法处理 componentMoved 事件。 | |
void | componentRemoved (ContainerEvent e) 通过在侦听器 a 和侦听器 b 上调用 componentRemoved 方法处理 componentRemoved 容器事件。 | |
void | componentResized (ComponentEvent e) 通过在侦听器 a 和侦听器 b 上调用 componentResized 方法处理 componentResized 事件。 | |
void | componentShown (ComponentEvent e) 通过在侦听器 a 和侦听器 b 上调用 componentShown 方法处理 componentShown 事件。 | |
void | focusGained (FocusEvent e) 通过在侦听器 a 和侦听器 b 上调用 focusGained 方法处理 focusGained 事件。 | |
void | focusLost (FocusEvent e) 通过在侦听器 a 和侦听器 b 上调用 focusLost 方法处理 focusLost 事件。 | |
static
| getListeners (EventListener l, Class <T> listenerType) 返回通过指定的 java.util.EventListener 链接为 Foo Listener 的所有对象的数组。 | |
void | hierarchyChanged (HierarchyEvent e) 通过在侦听器 a 和侦听器 b 上调用 hierarchyChanged 方法处理 hierarchyChanged 事件。 | |
void | inputMethodTextChanged (InputMethodEvent e) 通过在侦听器 a 和侦听器 b 上调用 inputMethodTextChanged 方法处理 inputMethodTextChanged 事件。 | |
void | itemStateChanged (ItemEvent e) 通过在侦听器 a 和侦听器 b 上调用 itemStateChanged 方法处理 itemStateChanged 事件。 | |
void | keyPressed (KeyEvent e) 通过在侦听器 a 和侦听器 b 上调用 keyPressed 方法处理 keyPressed 事件。 | |
void | keyReleased (KeyEvent e) 通过在侦听器 a 和侦听器 b 上调用 keyReleased 方法处理 keyReleased 事件。 | |
void | keyTyped (KeyEvent e) 通过在侦听器 a 和侦听器 b 上调用 keyTyped 方法处理 keyTyped 事件。 | |
void | mouseClicked (MouseEvent e) 通过在侦听器 a 和侦听器 b 上调用 mouseClicked 方法处理 mouseClicked 事件。 | |
void | mouseDragged (MouseEvent e) 通过在侦听器 a 和侦听器 b 上调用 mouseDragged 方法处理 mouseDragged 事件。 | |
void | mouseEntered (MouseEvent e) 通过在侦听器 a 和侦听器 b 上调用 mouseEntered 方法处理 mouseEntered 事件。 | |
void | mouseExited (MouseEvent e) 通过在侦听器 a 和侦听器 b 上调用 mouseExited 方法处理 mouseExited 事件。 | |
void | mouseMoved ( |