java.awt.event
public abstract class InputEvent extends ComponentEvent
KeyEvent
,
KeyAdapter
,
MouseEvent
,
MouseAdapter
,
MouseMotionAdapter
,
MouseWheelEvent
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
ALT_DOWN_MASK
The ALT key extended modifier.
|
static int |
ALT_GRAPH_DOWN_MASK
The ALT_GRAPH key extended modifier.
|
static int |
ALT_GRAPH_MASK
This is the bit mask which indicates the alt-graph modifier is in effect.
|
static int |
ALT_MASK
This is the bit mask which indicates the alt key is down.
|
static int |
BUTTON1_DOWN_MASK
The mouse button1 key extended modifier.
|
static int |
BUTTON1_MASK
This bit mask indicates mouse button one is down.
|
static int |
BUTTON2_DOWN_MASK
The mouse button2 extended modifier.
|
static int |
BUTTON2_MASK
This bit mask indicates mouse button two is down.
|
static int |
BUTTON3_DOWN_MASK
The mouse button3 extended modifier.
|
static int |
BUTTON3_MASK
This bit mask indicates mouse button three is down.
|
static int |
CTRL_DOWN_MASK
The CTRL key extended modifier.
|
static int |
CTRL_MASK
This is the bit mask which indicates the control key is down.
|
static int |
META_DOWN_MASK
The META key extended modifier.
|
static int |
META_MASK
This is the bit mask which indicates the meta key is down.
|
static int |
SHIFT_DOWN_MASK
The SHIFT key extended modifier.
|
static int |
SHIFT_MASK
This is the bit mask which indicates the shift key is down.
|
COMPONENT_FIRST, COMPONENT_HIDDEN, COMPONENT_LAST, COMPONENT_MOVED, COMPONENT_RESIZED, COMPONENT_SHOWN
ACTION_EVENT_MASK, ADJUSTMENT_EVENT_MASK, COMPONENT_EVENT_MASK, consumed, CONTAINER_EVENT_MASK, FOCUS_EVENT_MASK, HIERARCHY_BOUNDS_EVENT_MASK, HIERARCHY_EVENT_MASK, id, 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
source
Modifier and Type | Method and Description |
---|---|
void |
consume()
Consumes this event.
|
int |
getModifiers()
This method returns the old-style modifiers in effect for this event.
|
int |
getModifiersEx()
Returns the extended modifiers (new-style) for this event.
|
static String |
getModifiersExText(int modifiers)
Convert the extended modifier bitmask into a String, such as "Shift" or
"Ctrl+Button1".
|
long |
getWhen()
This method returns the timestamp when this event occurred.
|
boolean |
isAltDown()
This method tests whether or not the alt key was down during the event.
|
boolean |
isAltGraphDown()
This method tests whether or not the alt-graph modifier was in effect
during the event.
|
boolean |
isConsumed()
This method tests whether or not this event has been consumed.
|
boolean |
isControlDown()
This method tests whether or not the control key was down during the
event.
|
boolean |
isMetaDown()
This method tests whether or not the meta key was down during the event.
|
boolean |
isShiftDown()
This method tests whether or not the shift key was down during the event.
|
getComponent, paramString
getSource
public static final int SHIFT_MASK
SHIFT_DOWN_MASK
,
Constant Field Valuespublic static final int CTRL_MASK
CTRL_DOWN_MASK
,
Constant Field Valuespublic static final int META_MASK
META_DOWN_MASK
,
Constant Field Valuespublic static final int ALT_MASK
ALT_DOWN_MASK
,
Constant Field Valuespublic static final int ALT_GRAPH_MASK
ALT_GRAPH_DOWN_MASK
,
Constant Field Valuespublic static final int BUTTON1_MASK
BUTTON1_DOWN_MASK
,
Constant Field Valuespublic static final int BUTTON2_MASK
BUTTON2_DOWN_MASK
,
Constant Field Valuespublic static final int BUTTON3_MASK
BUTTON3_DOWN_MASK
,
Constant Field Valuespublic static final int SHIFT_DOWN_MASK
public static final int CTRL_DOWN_MASK
public static final int META_DOWN_MASK
public static final int ALT_DOWN_MASK
public static final int BUTTON1_DOWN_MASK
public static final int BUTTON2_DOWN_MASK
public static final int BUTTON3_DOWN_MASK
public static final int ALT_GRAPH_DOWN_MASK
public boolean isShiftDown()
public boolean isControlDown()
public boolean isMetaDown()
public boolean isAltDown()
public boolean isAltGraphDown()
public long getWhen()
public int getModifiers()
getModifiersEx()
public int getModifiersEx()
For an example of checking multiple modifiers, this code will return true only if SHIFT and BUTTON1 were pressed and CTRL was not:
int onmask = InputEvent.SHIFT_DOWN_MASK | InputEvent.BUTTON1_DOWN_MASK; int offmask = InputEvent.CTRL_DOWN_MASK; return (event.getModifiersEx() & (onmask | offmask)) == onmask;
public void consume()
public boolean isConsumed()
isConsumed
in class AWTEvent
public static String getModifiersExText(int modifiers)
modifiers
- the modifiers