start page | rating of books | rating of authors | reviews | copyrights

Java AWT

Previous Chapter 21
java.awt.event Reference
Next
 

MouseEvent (New)

Name

MouseEvent (New)

[Graphic: Figure from the text]

Description

Mouse events are generated when the user moves and clicks the mouse.

Class Definition

public class java.awt.event.MouseEvent
   extends java.awt.event.InputEvent {
  // Constants
  public final static int MOUSE_CLICKED;
  public final static int MOUSE_DRAGGED;
  public final static int MOUSE_ENTERED;
  public final static int MOUSE_EXITED;
  public final static int MOUSE_FIRST;
  public final static int MOUSE_LAST;
  public final static int MOUSE_MOVED;
  public final static int MOUSE_PRESSED;
  public final static int MOUSE_RELEASED;
  // Constructors
  public MouseEvent (Component source, int id, long when, int modifiers, int x,
    int y, int clickCount, boolean popupTrigger);
  // Instance Methods
  public int getClickCount();
  public synchronized Point getPoint();
  public int getX();
  public int getY();
  public boolean isPopupTrigger();
  public String paramString();
  public synchronized void translatePoint (int x, int y);
}

Constants

MOUSE_CLICKED

public final static int MOUSE_CLICKED

An event type ID indicating a mouse click.

MOUSE_DRAGGED

public final static int MOUSE_DRAGGED

An event type ID indicating a mouse move with the button held down.

MOUSE_ENTERED

public final static int MOUSE_ENTERED

An event type ID indicating that a mouse entered a component.

MOUSE_EXITED

public final static int MOUSE_EXITED

An event type ID indicating that a mouse left a component.

MOUSE_FIRST

public final static int MOUSE_FIRST

Specifies the beginning range of mouse event ID values.

MOUSE_LAST

public final static int MOUSE_LAST

Specifies the ending range of mouse event ID values.

MOUSE_MOVED

public final static int MOUSE_MOVED

An event type ID indicating a mouse move.

MOUSE_PRESSED

public final static int MOUSE_PRESSED

An event type ID indicating a mouse button press.

MOUSE_RELEASED

public final static int MOUSE_RELEASED

An event type ID indicating a mouse button release.

Constructors

MouseEvent

public MouseEvent (Component source, int id, long when, int modifiers, int x, int y, int clickCount, boolean popupTrigger)

Parameters

source

The object that generated the event.

id

The event type ID of the event.

when

When the event occurred, in milliseconds from the epoch.

modifiers

What modifier keys were pressed with this key.

x

The horizontal location of the event.

y

The vertical location of the event.

clickCount

The number of times the mouse button has been clicked.

popupTrigger

A flag indicating if this event is a popup trigger event.

Description

Constructs a MouseEvent with the given characteristics.

Instance Methods

getClickCount

public int getClickCount()

Returns

The number of consecutive mouse button clicks for this event.

getPoint

public synchronized Point getPoint()

Returns

The location where the event happened.

getX

public int getX()

Returns

The horizontal location where the event happened.

getY

public int getY()

Returns

The vertical location where the event happened.

isPopupTrigger

public boolean isPopupTrigger()

Returns

Returns true if this event is the popup menu event for the run-time system.

paramString

public String paramString()

Returns

String with current settings of the MouseEvent.

Overrides

ComponentEvent.paramString()

Description

Helper method for toString() to generate string of current settings.

translatePoint

public synchronized void translatePoint (int x, int y)

Parameters

x

The horizontal amount of translation.

y

The vertical amount of translation.

Description

Translates the location of the event by the given amounts.

See Also

Component, ComponentEvent, InputEvent, MouseAdapter, MouseListener, Point


Previous Home Next
MouseAdapter (New) Book Index MouseListener (New)

Java in a Nutshell Java Language Reference Java AWT Java Fundamental Classes Exploring Java