Professional Documents
Culture Documents
Oopr212 Midterms Reviewer
Oopr212 Midterms Reviewer
Event Listener
Object that includes a
method that gets executed in
response to the generated
events
Event listeners and the types
of events for which they are
used.
Listener-Type of Events • The class of the
object that responds
Example
to an event must
ActionListener-Action events contain a method that
accepts the event
Button clicks object created by the
AdjustmentListener- user’s action. Mouse Event
Adjustment events • In other words, when The MouseMotionListener
Scroll bar moves you register a interface provides methods
component (such as named mouseDragged()
ChangeListener-Change JFrame) to be a and mouseMoved() that
Events listener for events detect the mouse being
Slider is repositioned generated by another rolled or dragged across a
component (such as a component surface.
FocusListener-Keyboard JCheckBox), you
focus events need to write a The MouseListener
method that reacts to interface provides methods
Text field gains or loses
any generated event. named mousePressed(),
focus
mouseClicked(), and
ItemListener-Item events Listener mouseReleased() that are
Methods similar to the keyboard event
Check box changes status methods keyPressed(),
KeyListener-Keyboard ActionListener keyTyped(), and
events keyReleased().
actionPerformed(ActionEv
Text is entered ent) The MouseInputListener
interface implements all the
MouseListener-Mouse AdjustmentListener
methods in both the
events MouseListener and
adjustmentValueChanged(
Mouse clicks AdjustmentEvent) MouseMotionListener
interfaces.
MouseMotionListener-Mouse FocusListener
movement events
focusGained(FocusEvent)
Mouse rolls and
focusLost(FocusEvent)
WindowListener-Window
events ItemListener