[Chapter 21] MouseListener

#

| Chapter 21 java.awt.event Reference |

# MouseListener

## Name

MouseListener

##

## Description

Objects that implement the `MouseListener` interface can receive non-motion oriented `MouseEvent` objects. Listeners must first register themselves with objects that produce events. When events occur, they are then automatically propagated to all registered listeners.

## Interface Definition

    public abstract interface java.awt.event.MouseListener
       extends java.util.EventListener {
      // Instance Methods
      public abstract void mouseClicked (MouseEvent e);
      public abstract void mouseEntered (MouseEvent e);
      public abstract void mouseExited (MouseEvent e);
      public abstract void mousePressed (MouseEvent e);
      public abstract void mouseReleased (MouseEvent e);
    }

## Interface Methods

### mouseClicked

#### public abstract void mouseClicked (MouseEvent e)

Parameters

  e

    The key event that occurred.

Description

  Notifies the `MouseListener` that the mouse button was clicked (pressed and released).

### mouseEntered

#### public abstract void mouseEntered (MouseEvent e)

Parameters

  e

    The key event that occurred.

Description

  Notifies the `MouseListener` that the mouse cursor has been moved into a component's coordinate space.

### mouseExited

#### public abstract void mouseExited (MouseEvent e)

Parameters

  e

    The key event that occurred.

Description

  Notifies the `MouseListener` that the mouse cursor has been moved out of a component's coordinate space.

### mousePressed

#### public abstract void mousePressed (MouseEvent e)

Parameters

  e

    The key event that occurred.

Description

  Notifies the `MouseListener` that the mouse button was pressed.

### mouseReleased

#### public abstract void mouseReleased (MouseEvent e)

Parameters

  e

    The key event that occurred.

Description

  Notifies the `MouseListener` that the mouse button was released.

## See Also

`EventListener`, `MouseAdapter`, `MouseEvent`

MouseEvent |  | MouseMotionAdapter