public interface MouseListener extends EventListener
MouseMotionListener
.)
The class that is interested in processing a mouse event
either implements this interface (and all the methods it
contains) or extends the abstract MouseAdapter
class
(overriding only the methods of interest).
The listener object created from that class is then registered with a
component using the component's addMouseListener
method. A mouse event is generated when the mouse is pressed, released
clicked (pressed and released). A mouse event is also generated when
the mouse cursor enters or leaves a component. When a mouse event
occurs, the relevant method in the listener object is invoked, and
the MouseEvent
is passed to it.
MouseAdapter
,
MouseEvent
,
Tutorial: Writing a Mouse ListenerModifier and Type | Method and Description |
---|---|
void |
mouseClicked(MouseEvent e)
Invoked when the mouse button has been clicked (pressed
and released) on a component.
|
void |
mouseEntered(MouseEvent e)
Invoked when the mouse enters a component.
|
void |
mouseExited(MouseEvent e)
Invoked when the mouse exits a component.
|
void |
mousePressed(MouseEvent e)
Invoked when a mouse button has been pressed on a component.
|
void |
mouseReleased(MouseEvent e)
Invoked when a mouse button has been released on a component.
|
void mouseClicked(MouseEvent e)
void mousePressed(MouseEvent e)
void mouseReleased(MouseEvent e)
void mouseEntered(MouseEvent e)
void mouseExited(MouseEvent e)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2024, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.