The Java Listener Interfaces

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

The Java Listener Interfaces and their Methods

1 de 2

http://www.seasite.niu.edu/cs580java/java_listener_interfaces.htm

The Java Listener Interfaces and their Methods


(from Flannigan, Java in a Nutshell, 2nd Edition)

INTERFACE

INTERFACE METHODS

ADD METHOD

EVENT CLASS

ActionListener

actionPerformed (ActionEvent)

addActionListener()

ActionEvent

AdjustmentListener

adjustmentValueChanged(AdjustmentEvent)

addAdjustmentListener()

AdjustmentEvent

ComponentListener

componentHidden(ComponentEvent)

addComponentListener()

ComponentEvent

addContainerListener()

ContainerEvent

addFocusListener()

FocusEvent

itemStateChanged(ItemEvent)

addItemListener()

ItemEvent

keyPressed(KeyEvent)

addKeyListener()

KeyEvent

addMouseListener()

MouseEvent

addMouseMotionListener()

MouseEvent

componentMoved(ComponentEvent)
componentResized(ComponentEvent)
componentShown(ComponentEvent)
ContainerListener

componentAdded(ComponentEvent)
componentRemoved(ComponentEvent)

FocusListener

focusGained(FocusEvent)
focusLost(FocusEvent)

ItemListener
KeyListener

keyReleased(KeyEvent)
keyTyped(KeyEvent)
MouseListener

mouseClicked(MouseEvent)
mouseEntered(MouseEvent)
mouseExited(MouseEvent)
mousePressed(MouseEvent)
mouseReleased(MouseEvent)

MouseMotionListener mouseDragged(MouseEvent)
mouseMoved(MouseEvent)
Text:Listener

textValueChanged(TextEvent)

addText:Listener()

TextEvent

WindowListener

windowActivated(WindowEvent)

addWindowListener()

WindowEvent

windowClosed(WindowEvent)
windowClosing(WindowEvent)
windowDeactivated(WindowEvent)
windowDeiconified(WindowEvent)
windowIconified(WindowEvent)
windowOpened(WindowEvent)

AWT Components and the Events they Generate


Button
Checkbox

ActionEvent
ItemEvent

User clicked the button


User selected or deselected an item

CheckboxMenuItem

ItemEvent

User selected or deselected an item

27/04/2010 08:41 a.m.

The Java Listener Interfaces and their Methods

2 de 2

http://www.seasite.niu.edu/cs580java/java_listener_interfaces.htm

Choice

ItemEvent

User selected or deselected an item

Component

ComponentEvent
FocusEvent

Component moved, resized, hidden, or shown


Component gained or loast focus

KeyEvent

User pressed or released a key


User pressed or released a mouse button, mouse entered or exited a
component, or user moved or dragged mouse.

MouseEvent
Container

ContainerEvent

Component added to or removed from Container

List

ActionEvent

User double-clicked on a List item

MenuItem

ItemEvent
ActionEvent

User selected or deselected an item


User selected a menu item

ScrollBar

AdjustmentEvent

User moved the scrollbar

TextComponent
TextField

TextEvent
ActionEvent

User changed the text


User pressed Enter (finished editing text)

Window

WindowEvent

Window opened, closed, iconified, deiconified, or close requested

Event Masks and their Methods


MASK
AWTEvent.ACTION_EVENT_MASK

METHOD
processActionEvent()

AWTEvent.ADJUSTMENT_EVENT_MASK
AWTEvent.COMPONENT_EVENT_MASK
AWTEvent.CONTAINER_EVENT_MASK
AWTEvent.FOCUS_EVENT_MASK
AWTEvent.ITEM_EVENT_MASK
AWTEvent.KEY_EVENT_MASK
AWTEvent.MOUSE_EVENT_MASK
AWTEvent.MOUSE_MOTION_EVENT_MASK
AWTEvent.TEXT_EVENT_MASK
AWTEvent.WINDOW_EVENT_MASK

processAdjustmentEvent()
processComponentEvent()
processContainerEvent()
processFocusEvent()
processItemEvent()
processKeyEvent()
processMouseEvent()
processMouseMotionEvent()
processEventEvent()
processWindowEvent()

27/04/2010 08:41 a.m.

You might also like