java.awt.event
Class MouseEvent
- Serializable
This event is generated for a mouse event. There are three main categories
of mouse events: Regular events include pressing, releasing, and clicking
buttons, as well as moving over the boundary of the unobscured portion of
a component. Motion events include movement and dragging. Wheel events are
covered separately by the subclass MouseWheelEvent.
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.
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.
|
ALT_DOWN_MASK , ALT_GRAPH_DOWN_MASK , ALT_GRAPH_MASK , ALT_MASK , BUTTON1_DOWN_MASK , BUTTON1_MASK , BUTTON2_DOWN_MASK , BUTTON2_MASK , BUTTON3_DOWN_MASK , BUTTON3_MASK , CTRL_DOWN_MASK , CTRL_MASK , META_DOWN_MASK , META_MASK , SHIFT_DOWN_MASK , SHIFT_MASK |
ACTION_EVENT_MASK , ADJUSTMENT_EVENT_MASK , COMPONENT_EVENT_MASK , CONTAINER_EVENT_MASK , FOCUS_EVENT_MASK , HIERARCHY_BOUNDS_EVENT_MASK , HIERARCHY_EVENT_MASK , INPUT_METHOD_EVENT_MASK , INVOCATION_EVENT_MASK , ITEM_EVENT_MASK , KEY_EVENT_MASK , MOUSE_EVENT_MASK , MOUSE_MOTION_EVENT_MASK , MOUSE_WHEEL_EVENT_MASK , PAINT_EVENT_MASK , RESERVED_ID_MAX , TEXT_EVENT_MASK , WINDOW_EVENT_MASK , WINDOW_FOCUS_EVENT_MASK , WINDOW_STATE_EVENT_MASK , consumed , id |
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.
|
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.
|
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.
|
consume , getModifiers , getModifiersEx , getModifiersExText , getWhen , isAltDown , isAltGraphDown , isConsumed , isControlDown , isMetaDown , isShiftDown |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
BUTTON1
public static final int BUTTON1
This indicates that button 1 changed state.
BUTTON2
public static final int BUTTON2
This indicates that button 2 changed state.
BUTTON3
public static final int BUTTON3
This indicates that button 3 changed state.
MOUSE_CLICKED
public static final int MOUSE_CLICKED
This event id indicates that the mouse was clicked.
MOUSE_DRAGGED
public static final int MOUSE_DRAGGED
This event id indicates that the mouse was dragged over a component.
MOUSE_ENTERED
public static final int MOUSE_ENTERED
This event id indicates that the mouse entered a component.
MOUSE_EXITED
public static final int MOUSE_EXITED
This event id indicates that the mouse exited a component.
MOUSE_FIRST
public static final int MOUSE_FIRST
This is the first id in the range of event ids used by this class.
MOUSE_LAST
public static final int MOUSE_LAST
This is the last id in the range of event ids used by this class.
MOUSE_MOVED
public static final int MOUSE_MOVED
This event id indicates that the mouse was moved.
MOUSE_PRESSED
public static final int MOUSE_PRESSED
This event id indicates that the mouse was pressed.
MOUSE_RELEASED
public static final int MOUSE_RELEASED
This event id indicates that the mouse was released.
MOUSE_WHEEL
public static final int MOUSE_WHEEL
This event id indicates that the mouse wheel was rotated.
NOBUTTON
public static final int NOBUTTON
This indicates that no button changed state.
MouseEvent
public 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. Note that an invalid id leads to unspecified results.
source
- the source of the eventid
- the event idwhen
- the timestamp of when the event occurredmodifiers
- the modifier keys during the event, in old or new stylex
- the X coordinate of the mouse pointy
- the Y coordinate of the mouse pointclickCount
- the number of mouse clicks for this eventpopupTrigger
- true if this event triggers a popup menu
MouseEvent
public 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. Note that an invalid id leads to unspecified results.
source
- the source of the eventid
- the event idwhen
- the timestamp of when the event occurredmodifiers
- the modifier keys during the event, in old or new stylex
- the X coordinate of the mouse pointy
- the Y coordinate of the mouse pointclickCount
- the number of mouse clicks for this eventpopupTrigger
- true if this event triggers a popup menubutton
- the most recent mouse button to change state
getButton
public int getButton()
- the button that changed state
getClickCount
public int getClickCount()
This method returns the number of mouse clicks associated with this
event.
- the number of mouse clicks for this event
getMouseModifiersText
public static String getMouseModifiersText(int modifiers)
Returns a string describing the modifiers, such as "Shift" or
"Ctrl+Button1".
XXX Sun claims this can be localized via the awt.properties file - how
do we implement that?
modifiers
- the old-style modifiers to convert to text
- a string representation of the modifiers in this bitmask
getPoint
public Point getPoint()
This method returns a Point
for the x,y position of
the mouse pointer. This is relative to the source component.
- a
Point
for the event position
getX
public int getX()
This method returns the X coordinate of the mouse position. This is
relative to the source component.
getY
public int getY()
This method returns the Y coordinate of the mouse position. This is
relative to the source component.
isPopupTrigger
public boolean isPopupTrigger()
This method tests whether or not the event is a popup menu trigger. This
should be checked in both MousePressed and MouseReleased to be
cross-platform compatible, as different systems have different popup
triggers.
- true if the event is a popup menu trigger
paramString
public String paramString()
Returns a string identifying this event. This is formatted as the field
name of the id type, followed by the (x,y) point, the most recent button
changed, modifiers (if any), extModifiers (if any), and clickCount.
- paramString in interface ComponentEvent
- a string identifying this event
translatePoint
public void translatePoint(int dx,
int dy)
Translates the event coordinates by the specified x and y offsets.
dx
- the value to add to the X coordinate of this eventdy
- the value to add to the Y coordiante of this event
MouseEvent.java -- a mouse event
Copyright (C) 1999, 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.