APIdia Launch Partner
Top Description Constructors Methods
java.awt.event

public abstract Class MouseAdapter

extends Object
implements MouseListener, MouseWheelListener, MouseMotionListener
Class Inheritance
All Implemented Interfaces
java.awt.event.MouseMotionListener, java.util.EventListener, java.awt.event.MouseWheelListener, java.awt.event.MouseListener
Known Direct Subclasses
javax.swing.ToolTipManager, javax.swing.colorchooser.DefaultSwatchChooserPanel.RecentSwatchListener, javax.swing.colorchooser.DefaultSwatchChooserPanel.MainSwatchListener, javax.swing.event.MouseInputAdapter, javax.swing.plaf.basic.BasicComboPopup.InvocationMouseHandler, javax.swing.plaf.basic.BasicComboPopup.ListMouseHandler, javax.swing.plaf.basic.BasicScrollBarUI.TrackListener, javax.swing.plaf.basic.BasicScrollBarUI.ArrowButtonListener, javax.swing.plaf.basic.BasicSplitPaneDivider.MouseHandler, javax.swing.plaf.basic.BasicTabbedPaneUI.MouseHandler, javax.swing.plaf.basic.BasicTreeUI.MouseHandler, javax.swing.plaf.basic.BasicFileChooserUI.DoubleClickListener, javax.swing.plaf.metal.MetalFileChooserUI.SingleClickListener, javax.swing.text.html.FormView.MouseEventListener, javax.swing.text.html.HTMLEditorKit.LinkController, com.sun.java.swing.plaf.gtk.GTKFileChooserUI.DoubleClickListener, com.sun.java.swing.plaf.motif.MotifDesktopIconUI.DesktopIconMouseListener, com.sun.java.swing.plaf.motif.MotifMenuMouseListener, sun.awt.X11.InfoWindow.Balloon.ActionPerformer

An abstract adapter class for receiving mouse events. The methods in this class are empty. This class exists as convenience for creating listener objects.

Mouse events let you track when a mouse is pressed, released, clicked, moved, dragged, when it enters a component, when it exits and when a mouse wheel is moved.

Extend this class to create a MouseEvent (including drag and motion events) or/and MouseWheelEvent listener and override the methods for the events of interest. (If you implement the MouseListener, MouseMotionListener interface, you have to define all of the methods in it. This abstract class defines null methods for them all, so you can only have to define methods for events you care about.)

Create a listener object using the extended class and then register it with a component using the component's addMouseListener addMouseMotionListener, addMouseWheelListener methods. The relevant method in the listener object is invoked and the MouseEvent or MouseWheelEvent is passed to it in following cases:

Authors
Carl Quinn, Andrei Dmitriev
Since
1.1
See Also
MouseEvent, MouseWheelEvent, MouseListener, MouseMotionListener, MouseWheelListener, Tutorial: Writing a Mouse Listener

Constructor Summary

AccessConstructor and Description
protected
MouseAdapter()

Constructs a MouseAdapter.

Method Summary

Modifier and TypeMethod and Description
public void
mouseClicked(MouseEvent e)

Implements java.awt.event.MouseListener.mouseClicked.

Invoked when the mouse button has been clicked (pressed and released) on a component.

public void
mouseDragged(MouseEvent e)

Implements java.awt.event.MouseMotionListener.mouseDragged.

Invoked when a mouse button is pressed on a component and then dragged.

public void
mouseEntered(MouseEvent e)

Implements java.awt.event.MouseListener.mouseEntered.

Invoked when the mouse enters a component.

public void
mouseExited(MouseEvent e)

Implements java.awt.event.MouseListener.mouseExited.

Invoked when the mouse exits a component.

public void
mouseMoved(MouseEvent e)

Implements java.awt.event.MouseMotionListener.mouseMoved.

Invoked when the mouse cursor has been moved onto a component but no buttons have been pushed.

public void
mousePressed(MouseEvent e)

Implements java.awt.event.MouseListener.mousePressed.

Invoked when a mouse button has been pressed on a component.

public void
mouseReleased(MouseEvent e)

Implements java.awt.event.MouseListener.mouseReleased.

Invoked when a mouse button has been released on a component.

public void
mouseWheelMoved(MouseWheelEvent e)

Implements java.awt.event.MouseWheelListener.mouseWheelMoved.

Invoked when the mouse wheel is rotated.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MouseAdapterback to summary
protected MouseAdapter()

Constructs a MouseAdapter.

Method Detail

mouseClickedback to summary
public void mouseClicked(MouseEvent e)

Implements java.awt.event.MouseListener.mouseClicked.

Doc from java.awt.event.MouseListener.mouseClicked.

Invoked when the mouse button has been clicked (pressed and released) on a component.

mouseDraggedback to summary
public void mouseDragged(MouseEvent e)

Implements java.awt.event.MouseMotionListener.mouseDragged.

Doc from java.awt.event.MouseMotionListener.mouseDragged.

Invoked when a mouse button is pressed on a component and then dragged. MOUSE_DRAGGED events will continue to be delivered to the component where the drag originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component).

Due to platform-dependent Drag&Drop implementations, MOUSE_DRAGGED events may not be delivered during a native Drag&Drop operation.

Since
1.6
mouseEnteredback to summary
public void mouseEntered(MouseEvent e)

Implements java.awt.event.MouseListener.mouseEntered.

Doc from java.awt.event.MouseListener.mouseEntered.

Invoked when the mouse enters a component.

mouseExitedback to summary
public void mouseExited(MouseEvent e)

Implements java.awt.event.MouseListener.mouseExited.

Doc from java.awt.event.MouseListener.mouseExited.

Invoked when the mouse exits a component.

mouseMovedback to summary
public void mouseMoved(MouseEvent e)

Implements java.awt.event.MouseMotionListener.mouseMoved.

Doc from java.awt.event.MouseMotionListener.mouseMoved.

Invoked when the mouse cursor has been moved onto a component but no buttons have been pushed.

Since
1.6
mousePressedback to summary
public void mousePressed(MouseEvent e)

Implements java.awt.event.MouseListener.mousePressed.

Doc from java.awt.event.MouseListener.mousePressed.

Invoked when a mouse button has been pressed on a component.

mouseReleasedback to summary
public void mouseReleased(MouseEvent e)

Implements java.awt.event.MouseListener.mouseReleased.

Doc from java.awt.event.MouseListener.mouseReleased.

Invoked when a mouse button has been released on a component.

mouseWheelMovedback to summary
public void mouseWheelMoved(MouseWheelEvent e)

Implements java.awt.event.MouseWheelListener.mouseWheelMoved.

Doc from java.awt.event.MouseWheelListener.mouseWheelMoved.

Invoked when the mouse wheel is rotated.

Since
1.6