这些Java教程是针对JDK 8编写的。本页中描述的示例和实践不利用后续版本中引入的改进,并且可能使用不再可用的技术。
请参阅Java语言更改以获取Java SE 9及后续版本中更新的语言特性摘要。
请参阅JDK发行说明以获取有关所有JDK版本的新功能、增强功能和已删除或不推荐选项的信息。
在下表中,第一列给出了监听器接口的名称,其中包含链接到讨论该监听器的教程页面的链接,或者如果教程没有讨论该监听器,则包含链接到API文档的链接。第二列列出了相应的适配器类(如果有的话)。(有关使用适配器的讨论,请参阅使用适配器和内部类处理事件。)第三列列出了监听器接口包含的方法,并显示传递给该方法的事件对象的类型。通常,监听器、适配器和事件类型具有相同的名称前缀,但并非总是如此。
要查看哪些Swing组件可以触发哪些类型的事件,请参阅Swing组件支持的监听器。
ActionListener
无actionPerformed(ActionEvent)
AncestorListener
无ancestorAdded(AncestorEvent)
ancestorMoved(AncestorEvent)
ancestorRemoved(AncestorEvent)
CaretListener
无caretUpdate(CaretEvent)
CellEditorListener
无editingStopped(ChangeEvent)
editingCanceled(ChangeEvent)
ChangeListener
无stateChanged(ChangeEvent)
ComponentListener
ComponentAdapter
componentHidden(ComponentEvent)
componentMoved(ComponentEvent)
componentResized(ComponentEvent)
componentShown(ComponentEvent)
ContainerListener
ContainerAdapter
componentAdded(ContainerEvent)
componentRemoved(ContainerEvent)
DocumentListener
无changedUpdate(DocumentEvent)
insertUpdate(DocumentEvent)
removeUpdate(DocumentEvent)
ExceptionListener
无exceptionThrown(Exception)
FocusListener
FocusAdapter
focusGained(FocusEvent)
focusLost(FocusEvent)
HierarchyBoundsListener
HierarchyBoundsAdapter
ancestorMoved(HierarchyEvent)
ancestorResized(HierarchyEvent)
HierarchyListener
无hierarchyChanged(HierarchyEvent)
HyperlinkListener
无hyperlinkUpdate(HyperlinkEvent)
InputMethodListener
无caretPositionChanged(InputMethodEvent)
inputMethodTextChanged(InputMethodEvent)
InternalFrameListener
InternalFrameAdapter
internalFrameActivated(InternalFrameEvent)
internalFrameClosed(InternalFrameEvent)
internalFrameClosing(InternalFrameEvent)
internalFrameDeactivated(InternalFrameEvent)
internalFrameDeiconified(InternalFrameEvent)
internalFrameIconified(InternalFrameEvent)
internalFrameOpened(InternalFrameEvent)
ItemListener
无itemStateChanged(ItemEvent)
KeyListener
KeyAdapter
keyPressed(KeyEvent)
keyReleased(KeyEvent)
keyTyped(KeyEvent)
ListDataListener
无contentsChanged(ListDataEvent)
intervalAdded(ListDataEvent)
intervalRemoved(ListDataEvent)
ListSelectionListener
无valueChanged(ListSelectionEvent)
MenuDragMouseListener
无menuDragMouseDragged(MenuDragMouseEvent)
menuDragMouseEntered(MenuDragMouseEvent)
menuDragMouseExited(MenuDragMouseEvent)
menuDragMouseReleased(MenuDragMouseEvent)
MenuKeyListener
无menuKeyPressed(MenuKeyEvent)
menuKeyReleased(MenuKeyEvent)
menuKeyTyped(MenuKeyEvent)
MenuListener
无menuCanceled(MenuEvent)
menuDeselected(MenuEvent)
menuSelected(MenuEvent)
MouseInputListener
MouseListener
MouseMotionListener
MouseInputAdapter
MouseAdapter
mouseClicked(MouseEvent)
mouseEntered(MouseEvent)
mouseExited(MouseEvent)
mousePressed(MouseEvent)
mouseReleased(MouseEvent)
mouseDragged(MouseEvent)
mouseMoved(MouseEvent)
MouseAdapter(MouseEvent)
MouseListener
MouseAdapter
MouseInputAdapter
mouseClicked(MouseEvent)
mouseEntered(MouseEvent)
mouseExited(MouseEvent)
mousePressed(MouseEvent)
mouseReleased(MouseEvent)
MouseMotionListener
MouseMotionAdapter
MouseInputAdapter
mouseDragged(MouseEvent)
mouseMoved(MouseEvent)
MouseWheelListener
MouseAdapter
mouseWheelMoved(MouseWheelEvent)
MouseAdapter<MouseEvent>
PopupMenuListener
无popupMenuCanceled(PopupMenuEvent)
popupMenuWillBecomeInvisible(PopupMenuEvent)
popupMenuWillBecomeVisible(PopupMenuEvent)
PropertyChangeListener
无propertyChange(PropertyChangeEvent)
TableColumnModelListener
无columnAdded(TableColumnModelEvent)
columnMoved(TableColumnModelEvent)
columnRemoved(TableColumnModelEvent)
columnMarginChanged(ChangeEvent)
columnSelectionChanged(ListSelectionEvent)
TableModelListener
无tableChanged(TableModelEvent)
TreeExpansionListener
无treeCollapsed(TreeExpansionEvent)
treeExpanded(TreeExpansionEvent)
TreeModelListener
无treeNodesChanged(TreeModelEvent)
treeNodesInserted(TreeModelEvent)
treeNodesRemoved(TreeModelEvent)
treeStructureChanged(TreeModelEvent)
TreeSelectionListener
无valueChanged(TreeSelectionEvent)
TreeWillExpandListener
无treeWillCollapse(TreeExpansionEvent)
treeWillExpand(TreeExpansionEvent)
UndoableEditListener
无undoableEditHappened(UndoableEditEvent)
VetoableChangeListener
无vetoableChange(PropertyChangeEvent)
WindowFocusListener
WindowAdapter
windowGainedFocus(WindowEvent)
windowLostFocus(WindowEvent)
WindowListener
WindowAdapter
windowActivated(WindowEvent)
windowClosed(WindowEvent)
windowClosing(WindowEvent)
windowDeactivated(WindowEvent)
windowDeiconified(WindowEvent)
windowIconified(WindowEvent)
windowOpened(WindowEvent)
WindowStateListener
WindowAdapter
windowStateChanged(WindowEvent)