java.awt.event

Interface MouseListener

All Superinterfaces:
EventListener
Known Subinterfaces:
MouseInputListener
Known Implementing Classes:
AWTEventMulticaster, BasicButtonListener, BasicComboPopup.InvocationMouseHandler, BasicComboPopup.ListMouseHandler, BasicDesktopIconUI.MouseInputHandler, BasicFileChooserUI.DoubleClickListener, BasicInternalFrameUI.BorderListener, BasicInternalFrameUI.GlassPaneDispatcher, BasicListUI.MouseInputHandler, BasicMenuItemUI.MouseInputHandler, BasicMenuUI.MouseInputHandler, BasicScrollBarUI.ArrowButtonListener, BasicScrollBarUI.TrackListener, BasicSliderUI.TrackListener, BasicSplitPaneDivider.MouseHandler, BasicTabbedPaneUI.MouseHandler, BasicTableHeaderUI.MouseInputHandler, BasicTableUI.MouseInputHandler, BasicTextUI.BasicCaret, BasicToolBarUI.DockingListener, BasicTreeUI.MouseHandler, BasicTreeUI.MouseInputHandler, ChartPanel, DefaultCaret, FormView.MouseEventListener, HTMLEditorKit.LinkController, JMeterTreeListener, JRViewer.ImageMapPanel, MetalFileChooserUI.SingleClickListener, MetalToolBarUI.MetalDockingListener, MotifButtonListener, MotifCheckBoxMenuItemUI.MouseInputHandler, MotifDesktopIconUI.DesktopIconMouseListener, MotifMenuItemUI.MouseInputHandler, MotifMenuUI.MouseInputHandler, MotifRadioButtonMenuItemUI.MouseInputHandler, MotifTextUI.MotifCaret, MouseAdapter, MouseDragGestureRecognizer, MouseInputAdapter, PolarChartPanel, SynthSliderUI.SynthTrackListener, ToolTipManager, WindowsButtonListener, WindowsFileChooserUI.SingleClickListener, WindowsMenuUI.WindowsMouseInputHandler

public interface MouseListener
extends 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, MouseEvent, Tutorial: Writing a Mouse Listener, Reference: The Java Class Libraries (update file)

Method Summary

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.

Method Details

mouseClicked

public void mouseClicked(MouseEvent e)
Invoked when the mouse button has been clicked (pressed and released) on a component.
Usages and Demos :

View More Examples of mouseClicked(MouseEvent e)
   1: package diva.canvas.event;
   2: import java.awt.event.MouseListener;
   3: import java.awt.event.MouseMotionListener;
   4:         ...
   5:     MouseFilter _filter;
   6:     MouseListener _ml;
   7:     MouseMotionListener _mml;
   8:         ...
   9: 
  10:     public LayerMouseAdapter(MouseListener ml, MouseMotionListener mml) {
  11:         _ml = ml;
  12:         ...
  13:         if(_filter.accept(e)) {
  14:             _ml.mouseClicked(e);

View Full Code Here
   1: import java.awt.event.MouseEvent;
   2: import java.awt.event.MouseListener;
   3: import java.util.Date;
   4:         ...
   5:         {
   6:             MouseListener listener = (MouseListener)i.next();
   7:             switch (eventKind)
   8:         ...
   9:                 case MOUSE_CLICKED:
  10:                     listener.mouseClicked(mouseEvent);
  11:                     break;

View Full Code Here
   1: 
   2: public class MultiWindowTierMap extends AffyTieredMap implements MouseListener, NeoRubberBandListener {
   3:   boolean USE_SWING = true;
   4:         ...
   5:       for (int i=0; i<mlisteners.size(); i++) {
   6:     MouseListener listener = (MouseListener)mlisteners.get(i);
   7:         if (listener != null) {
   8:         ...
   9:       case MouseEvent.MOUSE_CLICKED:
  10:         listener.mouseClicked(pevt);
  11:         break;

View Full Code Here
   1: import java.awt.event.MouseEvent;
   2: import java.awt.event.MouseListener;
   3: import java.awt.event.MouseMotionListener;
   4:         ...
   5: public class SwingTerminal extends Component
   6:         implements VDUDisplay, KeyListener, MouseListener, MouseMotionListener, VDUBufferListener {
   7: 
   8:         ...
   9: 
  10:   private MouseListener mouseListener;
  11: 
  12:         ...
  13:         case MouseEvent.MOUSE_CLICKED:
  14:           mouseListener.mouseClicked(evt);

View Full Code Here
   1: import jp.ujihara.java.awt.event.MouseEvent;
   2: import jp.ujihara.java.awt.event.MouseListener;
   3: import jp.ujihara.java.awt.event.MouseMotionListener;
   4:         ...
   5: 
   6:   transient MouseListener mouseListener;
   7: 
   8:         ...
   9:         case MouseEvent.MOUSE_CLICKED:
  10:           mouseListener.mouseClicked(e);
  11:         break;

View Full Code Here

mouseEntered

public void mouseEntered(MouseEvent e)
Invoked when the mouse enters a component.
Usages and Demos :

View More Examples of mouseEntered(MouseEvent e)
   1: import java.awt.event.MouseEvent;
   2: import java.awt.event.MouseListener;
   3: import java.util.Date;
   4:         ...
   5:         {
   6:             MouseListener listener = (MouseListener)i.next();
   7:             switch (eventKind)
   8:         ...
   9:                 case MOUSE_ENTERED:
  10:                     listener.mouseEntered(mouseEvent);
  11:                     break;

View Full Code Here
   1: 
   2: public class MultiWindowTierMap extends AffyTieredMap implements MouseListener, NeoRubberBandListener {
   3:   boolean USE_SWING = true;
   4:         ...
   5:       for (int i=0; i<mlisteners.size(); i++) {
   6:     MouseListener listener = (MouseListener)mlisteners.get(i);
   7:         if (listener != null) {
   8:         ...
   9:       case MouseEvent.MOUSE_ENTERED:
  10:         listener.mouseEntered(pevt);
  11:         break;

View Full Code Here
   1: import java.awt.event.MouseEvent;
   2: import java.awt.event.MouseListener;
   3: import java.awt.event.MouseMotionListener;
   4:         ...
   5: public class SwingTerminal extends Component
   6:         implements VDUDisplay, KeyListener, MouseListener, MouseMotionListener, VDUBufferListener {
   7: 
   8:         ...
   9: 
  10:   private MouseListener mouseListener;
  11: 
  12:         ...
  13:         case MouseEvent.MOUSE_ENTERED:
  14:           mouseListener.mouseEntered(evt);

View Full Code Here
   1: import jp.ujihara.java.awt.event.MouseEvent;
   2: import jp.ujihara.java.awt.event.MouseListener;
   3: import jp.ujihara.java.awt.event.MouseMotionListener;
   4:         ...
   5: 
   6:   transient MouseListener mouseListener;
   7: 
   8:         ...
   9:         case MouseEvent.MOUSE_ENTERED:
  10:           mouseListener.mouseEntered(e);
  11:         break;

View Full Code Here

mouseExited

public void mouseExited(MouseEvent e)
Invoked when the mouse exits a component.
Usages and Demos :

View More Examples of mouseExited(MouseEvent e)
   1: import java.awt.event.MouseEvent;
   2: import java.awt.event.MouseListener;
   3: import java.util.Date;
   4:         ...
   5:         {
   6:             MouseListener listener = (MouseListener)i.next();
   7:             switch (eventKind)
   8:         ...
   9:                 case MOUSE_EXITED:
  10:                     listener.mouseExited(mouseEvent);
  11:                     break;

View Full Code Here
   1: 
   2: public class MultiWindowTierMap extends AffyTieredMap implements MouseListener, NeoRubberBandListener {
   3:   boolean USE_SWING = true;
   4:         ...
   5:       for (int i=0; i<mlisteners.size(); i++) {
   6:     MouseListener listener = (MouseListener)mlisteners.get(i);
   7:         if (listener != null) {
   8:         ...
   9:       case MouseEvent.MOUSE_EXITED:
  10:         listener.mouseExited(pevt);
  11:         break;

View Full Code Here
   1: import java.awt.event.MouseEvent;
   2: import java.awt.event.MouseListener;
   3: import java.awt.event.MouseMotionListener;
   4:         ...
   5: public class SwingTerminal extends Component
   6:         implements VDUDisplay, KeyListener, MouseListener, MouseMotionListener, VDUBufferListener {
   7: 
   8:         ...
   9: 
  10:   private MouseListener mouseListener;
  11: 
  12:         ...
  13:         case MouseEvent.MOUSE_EXITED:
  14:           mouseListener.mouseExited(evt);

View Full Code Here
   1: import jp.ujihara.java.awt.event.MouseEvent;
   2: import jp.ujihara.java.awt.event.MouseListener;
   3: import jp.ujihara.java.awt.event.MouseMotionListener;
   4:         ...
   5: 
   6:   transient MouseListener mouseListener;
   7: 
   8:         ...
   9:         case MouseEvent.MOUSE_EXITED:
  10:           mouseListener.mouseExited(e);
  11:         break;

View Full Code Here

mousePressed

public void mousePressed(MouseEvent e)
Invoked when a mouse button has been pressed on a component.
Usages and Demos :

View More Examples of mousePressed(MouseEvent e)
   1: package diva.canvas.event;
   2: import java.awt.event.MouseListener;
   3: import java.awt.event.MouseMotionListener;
   4:         ...
   5:     MouseFilter _filter;
   6:     MouseListener _ml;
   7:     MouseMotionListener _mml;
   8:         ...
   9: 
  10:     public LayerMouseAdapter(MouseListener ml, MouseMotionListener mml) {
  11:         _ml = ml;
  12:         ...
  13:         if(_filter.accept(e)) {
  14:             _ml.mousePressed(e);

View Full Code Here
   1: import java.awt.event.MouseEvent;
   2: import java.awt.event.MouseListener;
   3: import java.util.Date;
   4:         ...
   5:         {
   6:             MouseListener listener = (MouseListener)i.next();
   7:             switch (eventKind)
   8:         ...
   9:                 case MOUSE_PRESSED:
  10:                     listener.mousePressed(mouseEvent);
  11:                     break;

View Full Code Here
   1: 
   2: public class MultiWindowTierMap extends AffyTieredMap implements MouseListener, NeoRubberBandListener {
   3:   boolean USE_SWING = true;
   4:         ...
   5:       for (int i=0; i<mlisteners.size(); i++) {
   6:     MouseListener listener = (MouseListener)mlisteners.get(i);
   7:         if (listener != null) {
   8:         ...
   9:       case MouseEvent.MOUSE_PRESSED:
  10:         listener.mousePressed(pevt);
  11:         break;

View Full Code Here
   1: import java.awt.event.MouseEvent;
   2: import java.awt.event.MouseListener;
   3: import java.awt.event.MouseMotionListener;
   4:         ...
   5: public class SwingTerminal extends Component
   6:         implements VDUDisplay, KeyListener, MouseListener, MouseMotionListener, VDUBufferListener {
   7: 
   8:         ...
   9: 
  10:   private MouseListener mouseListener;
  11: 
  12:         ...
  13:         case MouseEvent.MOUSE_PRESSED:
  14:           mouseListener.mousePressed(evt);

View Full Code Here
   1: import jp.ujihara.java.awt.event.MouseEvent;
   2: import jp.ujihara.java.awt.event.MouseListener;
   3: import jp.ujihara.java.awt.event.MouseMotionListener;
   4:         ...
   5: 
   6:   transient MouseListener mouseListener;
   7: 
   8:         ...
   9:         case MouseEvent.MOUSE_PRESSED:
  10:           mouseListener.mousePressed(e);
  11:         break;

View Full Code Here

mouseReleased

public void mouseReleased(MouseEvent e)
Invoked when a mouse button has been released on a component.
Usages and Demos :

View More Examples of mouseReleased(MouseEvent e)
   1: package diva.canvas.event;
   2: import java.awt.event.MouseListener;
   3: import java.awt.event.MouseMotionListener;
   4:         ...
   5:     MouseFilter _filter;
   6:     MouseListener _ml;
   7:     MouseMotionListener _mml;
   8:         ...
   9: 
  10:     public LayerMouseAdapter(MouseListener ml, MouseMotionListener mml) {
  11:         _ml = ml;
  12:         ...
  13:         if(_filter.accept(e)) {
  14:             _ml.mouseReleased(e);

View Full Code Here
   1: import java.awt.event.MouseEvent;
   2: import java.awt.event.MouseListener;
   3: import java.util.Date;
   4:         ...
   5:         {
   6:             MouseListener listener = (MouseListener)i.next();
   7:             switch (eventKind)
   8:         ...
   9:                 case MOUSE_RELEASED:
  10:                     listener.mouseReleased(mouseEvent);
  11:                     break;

View Full Code Here
   1: 
   2: public class MultiWindowTierMap extends AffyTieredMap implements MouseListener, NeoRubberBandListener {
   3:   boolean USE_SWING = true;
   4:         ...
   5:       for (int i=0; i<mlisteners.size(); i++) {
   6:     MouseListener listener = (MouseListener)mlisteners.get(i);
   7:         if (listener != null) {
   8:         ...
   9:       case MouseEvent.MOUSE_RELEASED:
  10:         listener.mouseReleased(pevt);
  11:         break;

View Full Code Here
   1: import java.awt.event.MouseEvent;
   2: import java.awt.event.MouseListener;
   3: import java.awt.event.MouseMotionListener;
   4:         ...
   5: public class SwingTerminal extends Component
   6:         implements VDUDisplay, KeyListener, MouseListener, MouseMotionListener, VDUBufferListener {
   7: 
   8:         ...
   9: 
  10:   private MouseListener mouseListener;
  11: 
  12:         ...
  13:         case MouseEvent.MOUSE_RELEASED:
  14:           mouseListener.mouseReleased(evt);

View Full Code Here
   1: import java.awt.event.MouseEvent;
   2: import java.awt.event.MouseListener;
   3: import java.awt.event.MouseMotionListener;
   4:         ...
   5: 
   6:     protected MouseListener mouseListener;
   7: 
   8:         ...
   9:                         if (marquee != null)
  10:                             marquee.mouseReleased(null);
  11:                         if (mouseListener != null)
  12:         ...
  13:                             mouseListener.mouseReleased(null);

View Full Code Here