# 监听器 API 表

> 原文： [https://docs.oracle.com/javase/tutorial/uiswing/events/api.html](https://docs.oracle.com/javase/tutorial/uiswing/events/api.html)

在下面的表中，第一列给出了侦听器接口的名称，其中包含指向侦听器的教程页面的链接，或者如果教程没有讨论侦听器，则指向 API 文档的链接。第二列命名相应的适配器类（如果有）。 （有关使用适配器的讨论，请参阅[使用适配器和内部类来处理事件](generalrules.html#innerClasses)。）第三列列出了侦听器接口包含的方法，并显示了传递给方法的事件对象的类型。通常，侦听器，适配器和事件类型具有相同的名称前缀，但情况并非总是如此。

要查看哪些 Swing 组件可以触发哪种事件，请参阅 [Swing 组件支持的侦听器](eventsandcomponents.html)。

| 监听器接口 | 适配器类 | 听众方法 |
| --- | --- | --- |
| [`ActionListener`](actionlistener.html) | _ 无 _ | `actionPerformed(ActionEvent)` |
| [`AncestorListener`](https://docs.oracle.com/javase/8/docs/api/javax/swing/event/AncestorListener.html) | _ 无 _ | `ancestorAdded(AncestorEvent)`
`ancestorMoved(AncestorEvent)`
`ancestorRemoved(AncestorEvent)` |
| [`CaretListener`](caretlistener.html) | _ 无 _ | `caretUpdate(CaretEvent)` |
| [`CellEditorListener`](https://docs.oracle.com/javase/8/docs/api/javax/swing/event/CellEditorListener.html) | _ 无 _ | `editingStopped(ChangeEvent)`
`editingCanceled(ChangeEvent)` |
| [`ChangeListener`](changelistener.html) | _ 无 _ | `stateChanged(ChangeEvent)` |
| [`ComponentListener`](componentlistener.html) | `ComponentAdapter` | `componentHidden(ComponentEvent)`
`componentMoved(ComponentEvent)`
`componentResized(ComponentEvent)`
`componentShown(ComponentEvent)` |
| [`ContainerListener`](containerlistener.html) | `ContainerAdapter` | `componentAdded(ContainerEvent)`
`componentRemoved(ContainerEvent)` |
| [`DocumentListener`](documentlistener.html) | _ 无 _ | `changedUpdate(DocumentEvent)`
`insertUpdate(DocumentEvent)`
`removeUpdate(DocumentEvent)` |
| [`ExceptionListener`](https://docs.oracle.com/javase/8/docs/api/java/beans/ExceptionListener.html) | _ 无 _ | `exceptionThrown(Exception)` |
| [`FocusListener`](focuslistener.html) | `FocusAdapter` | `focusGained(FocusEvent)`
`focusLost(FocusEvent)` |
| [`HierarchyBoundsListener`](https://docs.oracle.com/javase/8/docs/api/java/awt/event/HierarchyBoundsListener.html) | `HierarchyBoundsAdapter` | `ancestorMoved(HierarchyEvent)`
`ancestorResized(HierarchyEvent)` |
| [`HierarchyListener`](https://docs.oracle.com/javase/8/docs/api/java/awt/event/HierarchyListener.html) | _ 无 _ | `hierarchyChanged(HierarchyEvent)` |
| [`HyperlinkListener`](https://docs.oracle.com/javase/8/docs/api/javax/swing/event/HyperlinkListener.html) | _ 无 _ | `hyperlinkUpdate(HyperlinkEvent)` |
| [`InputMethodListener`](https://docs.oracle.com/javase/8/docs/api/java/awt/event/InputMethodListener.html) | _ 无 _ | `caretPositionChanged(InputMethodEvent)`
`inputMethodTextChanged(InputMethodEvent)` |
| [`InternalFrameListener`](internalframelistener.html) | `InternalFrameAdapter` | `internalFrameActivated(InternalFrameEvent)`
`internalFrameClosed(InternalFrameEvent)`
`internalFrameClosing(InternalFrameEvent)`
`internalFrameDeactivated(InternalFrameEvent)`
`internalFrameDeiconified(InternalFrameEvent)`
`internalFrameIconified(InternalFrameEvent)`
`internalFrameOpened(InternalFrameEvent)` |
| [`ItemListener`](itemlistener.html) | _ 无 _ | `itemStateChanged(ItemEvent)` |
| [`KeyListener`](keylistener.html) | `KeyAdapter` | `keyPressed(KeyEvent)`
`keyReleased(KeyEvent)`
`keyTyped(KeyEvent)` |
| [`ListDataListener`](listdatalistener.html) | _ 无 _ | `contentsChanged(ListDataEvent)`
`intervalAdded(ListDataEvent)`
`intervalRemoved(ListDataEvent)` |
| [`ListSelectionListener`](listselectionlistener.html) | _ 无 _ | `valueChanged(ListSelectionEvent)` |
| [`MenuDragMouseListener`](https://docs.oracle.com/javase/8/docs/api/javax/swing/event/MenuDragMouseListener.html) | _ 无 _ | `menuDragMouseDragged(MenuDragMouseEvent)`
`menuDragMouseEntered(MenuDragMouseEvent)`
`menuDragMouseExited(MenuDragMouseEvent)`
`menuDragMouseReleased(MenuDragMouseEvent)` |
| [`MenuKeyListener`](https://docs.oracle.com/javase/8/docs/api/javax/swing/event/MenuKeyListener.html) | _ 无 _ | `menuKeyPressed(MenuKeyEvent)`
`menuKeyReleased(MenuKeyEvent)`
`menuKeyTyped(MenuKeyEvent)` |
| [`MenuListener`](https://docs.oracle.com/javase/8/docs/api/javax/swing/event/MenuListener.html) | _ 无 _ | `menuCanceled(MenuEvent)`
`menuDeselected(MenuEvent)`
`menuSelected(MenuEvent)` |
| `MouseInputListener`（扩展 [`MouseListener`](mouselistener.html) 和 [`MouseMotionListener`](mousemotionlistener.html) | `MouseInputAdapter`
`MouseAdapter` | `mouseClicked(MouseEvent)`
`mouseEntered(MouseEvent)`
`mouseExited(MouseEvent)`
`mousePressed(MouseEvent)`
`mouseReleased(MouseEvent)`
`mouseDragged(MouseEvent)`
`mouseMoved(MouseEvent)`
`MouseAdapter(MouseEvent)` |
| [`MouseListener`](mouselistener.html) | `MouseAdapter`，`MouseInputAdapter` | `mouseClicked(MouseEvent)`
`mouseEntered(MouseEvent)`
`mouseExited(MouseEvent)`
`mousePressed(MouseEvent)`
`mouseReleased(MouseEvent)` |
| [`MouseMotionListener`](mousemotionlistener.html) | `MouseMotionAdapter`，`MouseInputAdapter` | `mouseDragged(MouseEvent)`
`mouseMoved(MouseEvent)` |
| [`MouseWheelListener`](mousewheellistener.html) | `MouseAdapter` | `mouseWheelMoved(MouseWheelEvent)`
`MouseAdapter&lt;MouseEvent&gt;` |
| [`PopupMenuListener`](https://docs.oracle.com/javase/8/docs/api/javax/swing/event/PopupMenuListener.html) | _ 无 _ | `popupMenuCanceled(PopupMenuEvent)`
`popupMenuWillBecomeInvisible(PopupMenuEvent)`
`popupMenuWillBecomeVisible(PopupMenuEvent)` |
| [`PropertyChangeListener`](propertychangelistener.html) | _ 无 _ | `propertyChange(PropertyChangeEvent)` |
| [`TableColumnModelListener`](https://docs.oracle.com/javase/8/docs/api/javax/swing/event/TableColumnModelListener.html) | _ 无 _ | `columnAdded(TableColumnModelEvent)`
`columnMoved(TableColumnModelEvent)`
`columnRemoved(TableColumnModelEvent)`
`columnMarginChanged(ChangeEvent)`
`columnSelectionChanged(ListSelectionEvent)` |
| [`TableModelListener`](tablemodellistener.html) | _ 无 _ | `tableChanged(TableModelEvent)` |
| [`TreeExpansionListener`](treeexpansionlistener.html) | _ 无 _ | `treeCollapsed(TreeExpansionEvent)`
`treeExpanded(TreeExpansionEvent)` |
| [`TreeModelListener`](treemodellistener.html) | _ 无 _ | `treeNodesChanged(TreeModelEvent)`
`treeNodesInserted(TreeModelEvent)`
`treeNodesRemoved(TreeModelEvent)`
`treeStructureChanged(TreeModelEvent)` |
| [`TreeSelectionListener`](treeselectionlistener.html) | _ 无 _ | `valueChanged(TreeSelectionEvent)` |
| [`TreeWillExpandListener`](treewillexpandlistener.html) | _ 无 _ | `treeWillCollapse(TreeExpansionEvent)`
`treeWillExpand(TreeExpansionEvent)` |
| [`UndoableEditListener`](undoableeditlistener.html) | _ 无 _ | `undoableEditHappened(UndoableEditEvent)` |
| [`VetoableChangeListener`](https://docs.oracle.com/javase/8/docs/api/java/beans/VetoableChangeListener.html) | _ 无 _ | `vetoableChange(PropertyChangeEvent)` |
| [`WindowFocusListener`](windowlistener.html) | `WindowAdapter` | `windowGainedFocus(WindowEvent)`
`windowLostFocus(WindowEvent)` |
| [`WindowListener`](windowlistener.html) | `WindowAdapter` | `windowActivated(WindowEvent)`
`windowClosed(WindowEvent)`
`windowClosing(WindowEvent)`
`windowDeactivated(WindowEvent)`
`windowDeiconified(WindowEvent)`
`windowIconified(WindowEvent)`
`windowOpened(WindowEvent)` |
| [`WindowStateListener`](windowlistener.html) | `WindowAdapter` | `windowStateChanged(WindowEvent)` |