事件和接收者类型(java)
时间:2007-05-29 yycnet.yeah.net yyc译
所有AWT组件都被改变成包含addXXXListener()和removeXXXListener()方法,因此特定的接收器类型可从每个组件中增加和删除。
我们会注意到“XXX”在每个场合中同样表示自变量的方法,例如,addFooListener(FooListener fl)。
下面这张表格总结了通过提供addXXXListener()和removeXXXListener()方法,从而支持那些特定事件的相关事件、接收器、方法以及组件。事件,接收器接口及添加和删除方法 支持这个事件的组件
Event, listener interface and add- and remove-methods
|
Components supporting this event
|
ActionEventActionListeneraddActionListener()removeActionListener()
|
Button, List, TextField, MenuItem, and its derivatives including CheckboxMenuItem, Menu, and PopupMenu
|
AdjustmentEventAdjustmentListeneraddAdjustmentListener()removeAdjustmentListener()
|
ScrollbarAnything you create that implements the Adjustable interface
|
ComponentEventComponentListeneraddComponentListener()removeComponentListener()
|
Component and its derivatives, including Button, Canvas, Checkbox, Choice, Container, Panel, Applet, ScrollPane, Window, Dialog, FileDialog, Frame, Label, List, Scrollbar, TextArea, and TextField
|
ContainerEventContainerListeneraddContainerListener()removeContainerListener()
|
Container and its derivatives, including Panel, Applet, ScrollPane, Window, Dialog, FileDialog, and Frame
|
FocusEventFocusListeneraddFocusListener()removeFocusListener()
|
Component and its derivatives, including Button, Canvas, Checkbox, Choice, Container, Panel, Applet, ScrollPane, Window, Dialog, FileDialog, Frame Label, List, Scrollbar, TextArea, and TextField
|
KeyEventKeyListeneraddKeyListener()removeKeyListener()
|
Component and its derivatives, including Button, Canvas, Checkbox, Choice, Container, Panel, Applet, ScrollPane, Window, Dialog, FileDialog, Frame, Label, List, Scrollbar, TextArea, and TextField
|
MouseEvent (for both clicks and motion)MouseListeneraddMouseListener()removeMouseListener()
|
Component and its derivatives, including Button, Canvas, Checkbox, Choice, Container, Panel, Applet, ScrollPane, Window, Dialog, FileDialog, Frame, Label, List, Scrollbar, TextArea, and TextField
|
MouseEvent[55] (for both clicks and motion)MouseMotionListeneraddMouseMotionListener()removeMouseMotionListener()
|
Component and its derivatives, including Button, Canvas, Checkbox, Choice, Container, Panel, Applet, ScrollPane, Window, Dialog, FileDialog, Frame, Label, List, Scrollbar, TextArea, and TextField
|
WindowEventWindowListeneraddWindowListener()removeWindowListener()
|
Window and its derivatives, including Dialog, FileDialog, and Frame
|
ItemEventItemListeneraddItemListener()removeItemListener()
|
Checkbox, CheckboxMenuItem, Choice, List, and anything that implements the ItemSelectable interface
|
TextEventTextListeneraddTextListener()removeTextListener()
|
Anything derived from TextComponent, including TextArea and TextField
|
|