MouseListener
object with the component.
public interface MouseListener extends EventListener
For reasons of efficiency, the MouseListener
interface
only declares five methods:
public abstract void mouseClicked(MouseEvent e)
public abstract void mousePressed(MouseEvent e)
public abstract void mouseReleased(MouseEvent e)
public abstract void mouseEntered(MouseEvent e)
public abstract void mouseExited(MouseEvent e)
A mouse listener
does not respond to mouse dragged or mouse moved events because these are
too common. Responding to each of them, even with a noop method,
would result in many unnecessary method calls. Instead, mouse moved and mouse dragged events are responded to by the MouseMotionListener
interface.
public interface MouseMotionListener extends EventListener
The MouseMotionListener
interface declares these two methods
that are missing from MouseListener
:
public abstract void mouseDragged(MouseEvent e)
public abstract void mouseMoved(MouseEvent e)
If you don't care about mouse dragged and mouse moved events,
then you simply don't register a MouseMotionListener on the component
and the component won't bother to report such events.