java.awt.event
Interface MouseListener

All Superinterfaces:
EventListener sample code for java.util.EventListener definition code for java.util.EventListener
All Known Subinterfaces:
MouseInputListener sample code for javax.swing.event.MouseInputListener definition code for javax.swing.event.MouseInputListener
All Known Implementing Classes:
AWTEventMulticaster sample code for java.awt.AWTEventMulticaster definition code for java.awt.AWTEventMulticaster , BasicButtonListener sample code for javax.swing.plaf.basic.BasicButtonListener definition code for javax.swing.plaf.basic.BasicButtonListener , BasicComboPopup.InvocationMouseHandler sample code for javax.swing.plaf.basic.BasicComboPopup.InvocationMouseHandler definition code for javax.swing.plaf.basic.BasicComboPopup.InvocationMouseHandler , BasicComboPopup.ListMouseHandler sample code for javax.swing.plaf.basic.BasicComboPopup.ListMouseHandler definition code for javax.swing.plaf.basic.BasicComboPopup.ListMouseHandler , BasicDesktopIconUI.MouseInputHandler sample code for javax.swing.plaf.basic.BasicDesktopIconUI.MouseInputHandler definition code for javax.swing.plaf.basic.BasicDesktopIconUI.MouseInputHandler , BasicFileChooserUI.DoubleClickListener sample code for javax.swing.plaf.basic.BasicFileChooserUI.DoubleClickListener definition code for javax.swing.plaf.basic.BasicFileChooserUI.DoubleClickListener , BasicInternalFrameUI.BorderListener sample code for javax.swing.plaf.basic.BasicInternalFrameUI.BorderListener definition code for javax.swing.plaf.basic.BasicInternalFrameUI.BorderListener , BasicInternalFrameUI.GlassPaneDispatcher sample code for javax.swing.plaf.basic.BasicInternalFrameUI.GlassPaneDispatcher definition code for javax.swing.plaf.basic.BasicInternalFrameUI.GlassPaneDispatcher , BasicListUI.MouseInputHandler sample code for javax.swing.plaf.basic.BasicListUI.MouseInputHandler definition code for javax.swing.plaf.basic.BasicListUI.MouseInputHandler , BasicMenuItemUI.MouseInputHandler sample code for javax.swing.plaf.basic.BasicMenuItemUI.MouseInputHandler definition code for javax.swing.plaf.basic.BasicMenuItemUI.MouseInputHandler , BasicMenuUI.MouseInputHandler sample code for javax.swing.plaf.basic.BasicMenuUI.MouseInputHandler definition code for javax.swing.plaf.basic.BasicMenuUI.MouseInputHandler , BasicScrollBarUI.ArrowButtonListener sample code for javax.swing.plaf.basic.BasicScrollBarUI.ArrowButtonListener definition code for javax.swing.plaf.basic.BasicScrollBarUI.ArrowButtonListener , BasicScrollBarUI.TrackListener sample code for javax.swing.plaf.basic.BasicScrollBarUI.TrackListener definition code for javax.swing.plaf.basic.BasicScrollBarUI.TrackListener , BasicSliderUI.TrackListener sample code for javax.swing.plaf.basic.BasicSliderUI.TrackListener definition code for javax.swing.plaf.basic.BasicSliderUI.TrackListener , BasicSplitPaneDivider.MouseHandler sample code for javax.swing.plaf.basic.BasicSplitPaneDivider.MouseHandler definition code for javax.swing.plaf.basic.BasicSplitPaneDivider.MouseHandler , BasicTabbedPaneUI.MouseHandler sample code for javax.swing.plaf.basic.BasicTabbedPaneUI.MouseHandler definition code for javax.swing.plaf.basic.BasicTabbedPaneUI.MouseHandler , BasicTableHeaderUI.MouseInputHandler sample code for javax.swing.plaf.basic.BasicTableHeaderUI.MouseInputHandler definition code for javax.swing.plaf.basic.BasicTableHeaderUI.MouseInputHandler , BasicTableUI.MouseInputHandler sample code for javax.swing.plaf.basic.BasicTableUI.MouseInputHandler definition code for javax.swing.plaf.basic.BasicTableUI.MouseInputHandler , BasicTextUI.BasicCaret sample code for javax.swing.plaf.basic.BasicTextUI.BasicCaret definition code for javax.swing.plaf.basic.BasicTextUI.BasicCaret , BasicToolBarUI.DockingListener sample code for javax.swing.plaf.basic.BasicToolBarUI.DockingListener definition code for javax.swing.plaf.basic.BasicToolBarUI.DockingListener , BasicTreeUI.MouseHandler sample code for javax.swing.plaf.basic.BasicTreeUI.MouseHandler definition code for javax.swing.plaf.basic.BasicTreeUI.MouseHandler , BasicTreeUI.MouseInputHandler sample code for javax.swing.plaf.basic.BasicTreeUI.MouseInputHandler definition code for javax.swing.plaf.basic.BasicTreeUI.MouseInputHandler , DefaultCaret sample code for javax.swing.text.DefaultCaret definition code for javax.swing.text.DefaultCaret , FormView.MouseEventListener sample code for javax.swing.text.html.FormView.MouseEventListener definition code for javax.swing.text.html.FormView.MouseEventListener , HTMLEditorKit.LinkController sample code for javax.swing.text.html.HTMLEditorKit.LinkController definition code for javax.swing.text.html.HTMLEditorKit.LinkController , MetalFileChooserUI.SingleClickListener sample code for javax.swing.plaf.metal.MetalFileChooserUI.SingleClickListener definition code for javax.swing.plaf.metal.MetalFileChooserUI.SingleClickListener , MetalToolBarUI.MetalDockingListener sample code for javax.swing.plaf.metal.MetalToolBarUI.MetalDockingListener definition code for javax.swing.plaf.metal.MetalToolBarUI.MetalDockingListener , MouseAdapter sample code for java.awt.event.MouseAdapter definition code for java.awt.event.MouseAdapter , MouseDragGestureRecognizer sample code for java.awt.dnd.MouseDragGestureRecognizer definition code for java.awt.dnd.MouseDragGestureRecognizer , MouseInputAdapter sample code for javax.swing.event.MouseInputAdapter definition code for javax.swing.event.MouseInputAdapter , ToolTipManager sample code for javax.swing.ToolTipManager definition code for javax.swing.ToolTipManager

public interface MouseListener
extends EventListener sample code for java.util.EventListener definition code for java.util.EventListener

The listener interface for receiving "interesting" mouse events (press, release, click, enter, and exit) on a component. (To track mouse moves and mouse drags, use the 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.

Since:
1.1
See Also:
MouseAdapter sample code for java.awt.event.MouseAdapter definition code for java.awt.event.MouseAdapter , MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent , Tutorial: Writing a Mouse Listener, Reference: The Java Class Libraries (update file)

Method Summary
 void mouseClicked sample code for java.awt.event.MouseListener.mouseClicked(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseClicked(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
          Invoked when the mouse button has been clicked (pressed and released) on a component.
 void mouseEntered sample code for java.awt.event.MouseListener.mouseEntered(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseEntered(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
          Invoked when the mouse enters a component.
 void mouseExited sample code for java.awt.event.MouseListener.mouseExited(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseExited(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
          Invoked when the mouse exits a component.
 void mousePressed sample code for java.awt.event.MouseListener.mousePressed(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mousePressed(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
          Invoked when a mouse button has been pressed on a component.
 void mouseReleased sample code for java.awt.event.MouseListener.mouseReleased(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseReleased(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
          Invoked when a mouse button has been released on a component.
 

Method Detail

mouseClicked sample code for java.awt.event.MouseListener.mouseClicked(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseClicked(java.awt.event.MouseEvent)

void mouseClicked(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
Invoked when the mouse button has been clicked (pressed and released) on a component.


mousePressed sample code for java.awt.event.MouseListener.mousePressed(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mousePressed(java.awt.event.MouseEvent)

void mousePressed(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
Invoked when a mouse button has been pressed on a component.


mouseReleased sample code for java.awt.event.MouseListener.mouseReleased(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseReleased(java.awt.event.MouseEvent)

void mouseReleased(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
Invoked when a mouse button has been released on a component.


mouseEntered sample code for java.awt.event.MouseListener.mouseEntered(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseEntered(java.awt.event.MouseEvent)

void mouseEntered(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
Invoked when the mouse enters a component.


mouseExited sample code for java.awt.event.MouseListener.mouseExited(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseExited(java.awt.event.MouseEvent)

void mouseExited(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
Invoked when the mouse exits a component.