Event, listener interface and add- and remove-methods | Components supporting this event |
---|---|
ActionEvent ActionListener addActionListener() removeActionListener() | Button, List, TextField, MenuItem, and its derivatives including CheckboxMenuItem, Menu, and PopupMenu |
AdjustmentEvent AdjustmentListener addAdjustmentListener() removeAdjustmentListener() | Scrollbar Anything you create that implements the Adjustable interface |
ComponentEvent ComponentListener addComponentListener() removeComponentListener() | Component and its derivatives, including Button, Canvas, Checkbox, Choice, Container, Panel, Applet, ScrollPane, Window, Dialog, FileDialog, Frame, Label, List, Scrollbar, TextArea, and TextField |
ContainerEvent ContainerListener addContainerListener() removeContainerListener() | Container and its derivatives, including Panel, Applet, ScrollPane, Window, Dialog, FileDialog, and Frame |
FocusEvent FocusListener addFocusListener() removeFocusListener() | Component and its derivatives, including Button, Canvas, Checkbox, Choice, Container, Panel, Applet, ScrollPane, Window, Dialog, FileDialog, Frame Label, List, Scrollbar, TextArea, and TextField |
KeyEvent KeyListener addKeyListener() 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) MouseListener addMouseListener() 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 (for both clicks and motion) MouseMotionListener addMouseMotionListener() removeMouseMotionListener() | Component and its derivatives, including Button, Canvas, Checkbox, Choice, Container, Panel, Applet, ScrollPane, Window, Dialog, FileDialog, Frame, Label, List, Scrollbar, TextArea, and TextField |
WindowEvent WindowListener addWindowListener() removeWindowListener() | Window and its derivatives, including Dialog, FileDialog, and Frame |
ItemEvent ItemListener addItemListener() removeItemListener() | Checkbox, CheckboxMenuItem, Choice, List, and anything that implements the ItemSelectable interface |
TextEvent TextListener addTextListener() removeTextListener() | Anything derived from TextComponent, including TextArea and TextField |
Component type | Events supported by this component |
---|---|
Adjustable | AdjustmentEvent |
Applet | ContainerEvent, FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
Button | ActionEvent, FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
Canvas | FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
Checkbox | ItemEvent, FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
CheckboxMenuItem | ActionEvent, ItemEvent |
Choice | ItemEvent, FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
Component | FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
Container | ContainerEvent, FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
Dialog | ContainerEvent, WindowEvent, FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
FileDialog | ContainerEvent, WindowEvent, FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
Frame | ContainerEvent, WindowEvent, FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
Label | FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
List | ActionEvent, FocusEvent, KeyEvent, MouseEvent, ItemEvent, ComponentEvent |
Menu | ActionEvent |
MenuItem | ActionEvent |
Panel | ContainerEvent, FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
PopupMenu | ActionEvent |
Scrollbar | AdjustmentEvent, FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
ScrollPane | ContainerEvent, FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
TextArea | TextEvent, FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
TextComponent | TextEvent, FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
TextField | ActionEvent, TextEvent, FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
Window | ContainerEvent, WindowEvent, FocusEvent, KeyEvent, MouseEvent, ComponentEvent |
Listener interface w/ adapter | Methods in interface |
---|---|
ActionListener | actionPerformed(ActionEvent) |
AdjustmentListener | adjustmentValueChanged( AdjustmentEvent) |
ComponentListener ComponentAdapter | componentHidden(ComponentEvent) componentShown(ComponentEvent) componentMoved(ComponentEvent) componentResized(ComponentEvent) |
ContainerListener ContainerAdapter | componentAdded(ContainerEvent) componentRemoved(ContainerEvent) |
FocusListener FocusAdapter | focusGained(FocusEvent) focusLost(FocusEvent) |
KeyListener KeyAdapter | keyPressed(KeyEvent) keyReleased(KeyEvent) keyTyped(KeyEvent) |
MouseListener MouseAdapter | mouseClicked(MouseEvent) mouseEntered(MouseEvent) mouseExited(MouseEvent) mousePressed(MouseEvent) mouseReleased(MouseEvent) |
MouseMotionListener MouseMotionAdapter | mouseDragged(MouseEvent) mouseMoved(MouseEvent) |
WindowListener WindowAdapter | windowOpened(WindowEvent) windowClosing(WindowEvent) windowClosed(WindowEvent) windowActivated(WindowEvent) windowDeactivated(WindowEvent) windowIconified(WindowEvent) windowDeiconified(WindowEvent) |
ItemListener | itemStateChanged(ItemEvent) |
TextListener | textValueChanged(TextEvent) |
class MyWindowListener extends WindowAdapter {public void windowClosing(WindowEvent e) {System.exit(0);}}
class MyWindowListener extends WindowAdapter {public void WindowClosing(WindowEvent e) {System.exit(0);}}