AWT MouseEvent类
此事件表明在一个组件中发生鼠标动作。这种低层次的活动所产生的一个组件对象的鼠标事件和鼠标移动事件。
-
按下鼠标按钮
-
释放鼠标按钮
-
点击鼠标按钮(按下并释放)
-
鼠标光标进入视野开阔的部分部件几何
-
遮掩部分组件的几何形状的鼠标光标退出
-
鼠标指针移动
-
拖动鼠标
类的声明
以下是java.awt.event.MouseEvent 类的声明:
public class MouseEvent extends InputEvent
字段域
以下是字段java.awt.event.MouseEvent 类:
-
static int BUTTON1 --Indicates mouse button #1; used by getButton()
-
static int BUTTON2 --Indicates mouse button #2; used by getButton()
-
static int BUTTON3 --Indicates mouse button #3; used by getButton()
-
static int MOUSE_CLICKED --The "mouse clicked" event
-
static int MOUSE_DRAGGED --The "mouse dragged" event
-
static int MOUSE_ENTERED --The "mouse entered" event
-
static int MOUSE_EXITED --The "mouse exited" event
-
static int MOUSE_FIRST --The first number in the range of ids used for mouse events
-
static int MOUSE_LAST -- The last number in the range of ids used for mouse events
-
static int MOUSE_MOVED --The "mouse moved" event
-
static int MOUSE_PRESSED -- The "mouse pressed" event
-
static int MOUSE_RELEASED --The "mouse released" event
-
static int MOUSE_WHEEL --The "mouse wheel" event
-
static int NOBUTTON --Indicates no mouse buttons; used by getButton()
-
static int VK_WINDOWS --Constant for the Microsoft Windows "Windows" key.
类的构造函数
S.N. | 构造方法 & 描述 |
---|---|
1 |
MouseEvent(Component source, int id, long when, int modifiers, int x, int y, int clickCount, boolean popupTrigger) Constructs a MouseEvent object with the specified source component, type, modifiers, coordinates, and click count. |
2 |
MouseEvent(Component source, int id, long when, int modifiers, int x, int y, int clickCount, boolean popupTrigger, int button) Constructs a MouseEvent object with the specified source component, type, modifiers, coordinates, and click count. |
3 |
MouseEvent(Component source, int id, long when, int modifiers, int x, int y, int xAbs, int yAbs, int clickCount, boolean popupTrigger, int button) Constructs a MouseEvent object with the specified source component, type, modifiers, coordinates, absolute coordinates, and click count. |
类方法
S.N. | 方法和说明 |
---|---|
1 |
int getButton() Returns which, if any, of the mouse buttons has changed state. |
2 |
int getClickCount() Returns the number of mouse clicks associated with this event. |
3 |
Point getLocationOnScreen() Returns the absolute x, y position of the event. |
4 |
static String getMouseModifiersText(int modifiers) Returns a String describing the modifier keys and mouse buttons that were down during the event, such as "Shift", or "Ctrl+Shift". |
5 |
Point getPoint() Returns the x,y position of the event relative to the source component. |
6 |
int getX() Returns the horizontal x position of the event relative to the source component. |
7 |
int getXOnScreen() Returns the absolute horizontal x position of the event. |
8 |
int getY() Returns the vertical y position of the event relative to the source component. |
9 |
int getYOnScreen() Returns the absolute vertical y position of the event. |
10 | boolean isPopupTrigger() Returns whether or not this mouse event is the popup menu trigger event for the platform. |
11 |
String paramString() Returns a parameter string identifying this event. |
12 |
void translatePoint(int x, int y) Translates the event's coordinates to a new position by adding specified x (horizontal) and y (vertical) offsets. |
继承的方法
这个类继承的方法从以下类:
-
java.awt.event.InputEvent
-
java.awt.event.ComponentEvent
-
java.awt.AWTEvent
-
java.util.EventObject
-
java.lang.Object