java.awt.event
public class MouseEvent extends InputEvent
A mouse event is tied to the unobstructed visible component that the
mouse cursor was over at the time of the action. The button that was
most recently pressed is the only one that shows up in
getModifiers
, and is returned by getButton
,
while all buttons that are down show up in getModifiersEx
.
Drag events may be cut short if native drag-and-drop operations steal the event. Likewise, if a mouse drag exceeds the bounds of a window or virtual device, some platforms may clip the path to fit in the bounds of the component.
Since: 1.1
See Also: MouseAdapter MouseListener MouseMotionAdapter MouseMotionListener MouseWheelListener
UNKNOWN: updated to 1.4
Field Summary | |
---|---|
static int | BUTTON1
This indicates that button 1 changed state.
|
static int | BUTTON2
This indicates that button 2 changed state.
|
static int | BUTTON3
This indicates that button 3 changed state.
|
static int | MOUSE_CLICKED This event id indicates that the mouse was clicked. |
static int | MOUSE_DRAGGED This event id indicates that the mouse was dragged over a component. |
static int | MOUSE_ENTERED This event id indicates that the mouse entered a component. |
static int | MOUSE_EXITED This event id indicates that the mouse exited a component. |
static int | MOUSE_FIRST This is the first id in the range of event ids used by this class. |
static int | MOUSE_LAST This is the last id in the range of event ids used by this class. |
static int | MOUSE_MOVED This event id indicates that the mouse was moved. |
static int | MOUSE_PRESSED This event id indicates that the mouse was pressed. |
static int | MOUSE_RELEASED This event id indicates that the mouse was released. |
static int | MOUSE_WHEEL
This event id indicates that the mouse wheel was rotated.
|
static int | NOBUTTON
This indicates that no button changed state.
|
Constructor Summary | |
---|---|
MouseEvent(Component source, int id, long when, int modifiers, int x, int y, int clickCount, boolean popupTrigger, int button)
Initializes a new instance of MouseEvent with the specified
information. | |
MouseEvent(Component source, int id, long when, int modifiers, int x, int y, int clickCount, boolean popupTrigger)
Initializes a new instance of MouseEvent with the specified
information. |
Method Summary | |
---|---|
int | getButton()
Returns which button, if any, was the most recent to change state. |
int | getClickCount()
This method returns the number of mouse clicks associated with this
event.
|
static String | getMouseModifiersText(int modifiers)
Returns a string describing the modifiers, such as "Shift" or
"Ctrl+Button1".
|
Point | getPoint()
This method returns a Point for the x,y position of
the mouse pointer. |
int | getX()
This method returns the X coordinate of the mouse position. |
int | getY()
This method returns the Y coordinate of the mouse position. |
boolean | isPopupTrigger()
This method tests whether or not the event is a popup menu trigger. |
String | paramString()
Returns a string identifying this event. |
void | translatePoint(int dx, int dy)
Translates the event coordinates by the specified x and y offsets.
|
Since: 1.4
See Also: getButton
Since: 1.4
See Also: getButton
Since: 1.4
See Also: getButton
Since: 1.4
Since: 1.4
See Also: getButton
MouseEvent
with the specified
information. Note that an invalid id leads to unspecified results.
Parameters: source the source of the event id the event id when the timestamp of when the event occurred modifiers the modifier keys during the event, in old or new style x the X coordinate of the mouse point y the Y coordinate of the mouse point clickCount the number of mouse clicks for this event popupTrigger true if this event triggers a popup menu button the most recent mouse button to change state
Throws: IllegalArgumentException if source is null or button is invalid
Since: 1.4
MouseEvent
with the specified
information. Note that an invalid id leads to unspecified results.
Parameters: source the source of the event id the event id when the timestamp of when the event occurred modifiers the modifier keys during the event, in old or new style x the X coordinate of the mouse point y the Y coordinate of the mouse point clickCount the number of mouse clicks for this event popupTrigger true if this event triggers a popup menu
Throws: IllegalArgumentException if source is null
Returns: the button that changed state
Since: 1.4
Returns: the number of mouse clicks for this event
Parameters: modifiers the old-style modifiers to convert to text
Returns: a string representation of the modifiers in this bitmask
Point
for the x,y position of
the mouse pointer. This is relative to the source component.
Returns: a Point
for the event position
Returns: the x coordinate
Returns: the y coordinate
Returns: true if the event is a popup menu trigger
Returns: a string identifying this event
Parameters: dx the value to add to the X coordinate of this event dy the value to add to the Y coordiante of this event