An event which indicates that a mouse action occurred in a component.
A mouse action is considered to occur in a particular component if and only
if the mouse cursor is over the unobscured part of the component's bounds
when the action happens.
Component bounds can be obscurred by the visible component's children or by a
menu or by a top-level window.
This event is used both for mouse events (click, enter, exit) and mouse
motion events (moves and drags).
The "mouse wheel" event. This is the only
public static final int MOUSE_WHEEL
Constructor Detail
getX
- MOUSE_CLICKED
- The mouse clicked event type.
public static final int MOUSE_CLICKED
- MOUSE_DRAGGED
- The mouse dragged event type.
public static final int MOUSE_DRAGGED
- MOUSE_ENTERED
- The mouse entered event type.
public static final int MOUSE_ENTERED
- MOUSE_EXITED
- The mouse exited event type.
public static final int MOUSE_EXITED
- MOUSE_FIRST
- Marks the first integer id for the range of mouse event ids.
public static final int MOUSE_FIRST
- MOUSE_LAST
- Marks the last integer id for the range of mouse event ids.
public static final int MOUSE_LAST
- MOUSE_MOVED
- The mouse moved event type.
public static final int MOUSE_MOVED
- MOUSE_PRESSED
- The mouse pressed event type.
public static final int MOUSE_PRESSED
- MOUSE_RELEASED
- The mouse released event type.
public static final int MOUSE_RELEASED
The "mouse wheel" event. This is the only
MouseWheelEvent
.
It occurs when a mouse equipped with a wheel has its wheel rotated.public static final int MOUSE_WHEEL
Important Classes and Interfaces
These classes and interfaces are defined in java.awt.event. The first three are the most commonly used.MouseEvent | A MouseEvent object is passed to all mouse listeners. The most useful information in a MouseEvent is the x and y coordinates of the mouse cursor. | ||
MouseListener | Interface for mouse presses, releases, clicks, enters, and exits. | ||
MouseMotionListener | Interface for mouse moves and drags. | ||
MouseInputListener | Interface combination of MouseListener and MouseMotionListener. | ||
MouseAdapter | Class useful for writing anonymous listener for mouse button presses, entering, ... | ||
MouseMotionAdapter | Class useful for writing anonymous listener for mouse movement. | ||
Handling the mouse wheel. | |||
MouseWheelEvent | Object passed to mouseWheelMoved. Subclass of MouseEvent. | ||
MouseWheelListener | Interface to handle wheel movements. Write mouseWheelMoved(MouseWheelEvent we) |
public MouseEvent(Component source,int id,long when,int modifiers,int x,int y, int clickCount,boolean popupTrigger,int button)
source
- theComponent
that originated the eventid
- the integer that identifies the eventwhen
- a long int that gives the time the event occurredmodifiers
- the modifier keys down during event (e.g. shift, ctr l, alt, meta) Either extended _DOWN_MASK or old _MASK modifiers should be used, but both models should not be mixed in one event. Use of the extended modifiers is preferred.x
- the horizontal x coordinate for the mouse locationy
- the vertical y coordinate for the mouse locationclickCount
- the number of mouse clicks associated with eventpopupTrigger
- a boolean, true if this event is a trigger for a popup menubutton
- which of the mouse buttons has changed state.NOBUTTON
,BUTTON1
,BUTTON2
orBUTTON3
.
Method Detail
getX
public int getX()
- Returns the x position of the event relative to the source component.
public int getY()
- Returns the y position of the event relative to the source component.
public Point getPoint()
- Returns the x,y position of the event relative to the source component.
public synchronized void translatePoint(int x, int y)
- Translates the coordinate position of the event by x, y.
-
- Parameters:
- x - the x value added to the current x coordinate position
- y - the y value added to the current y coordinate position
public int getClickCount()
- Return the number of mouse clicks associated with this event.
public boolean isPopupTrigger()
- Returns whether or not this mouse event is the popup-menu trigger event for the platform.
public String paramString()
-
- Overrides:
- paramString in class ComponentEvent
0 comments:
Post a Comment