Action events are fired off when the user performs an action on a component, such as pushing a button, double-clicking on a list item, or selecting a menu item. There is only one action event type, ACTION_PERFORMED.
public class java.awt.event.ActionEvent extends java.awt.AWTEvent { // Constants public final static int ACTION_FIRST; public final static int ACTION_LAST; public final static int ACTION_PERFORMED; public final static int ALT_MASK; public final static int CTRL_MASK; public final static int META_MASK; public final static int SHIFT_MASK; // Constructors public ActionEvent (Object source, int id, String command); public ActionEvent (Object source, int id, String command, int modifiers); // Instance Methods public String getActionCommand(); public int getModifiers();
public String paramString(); }
public final static int ACTION_FIRST
Specifies the beginning range of action event ID values.
public final static int ACTION_LAST
Specifies the ending range of action event ID values.
public final static int ACTION_PERFORMED
The only action event type; it indicates that the user has performed an action.
public final static int ALT_MASK
A constant representing the ALT key. ORed with other masks to form modifiers setting of an AWTEvent.
public final static int CTRL_MASK
A constant representing the Control key. ORed with other masks to form modifiers setting of an AWTEvent.
public final static int META_MASK
A constant representing the META key. ORed with other masks to form modifiers setting of an AWTEvent.
public final static int SHIFT_MASK
A constant representing the Shift key. ORed with other masks to form modifiers setting of an AWTEvent.
public ActionEvent (Object source, int id, String command)
Parameters | source | The object that generated the event. |
id | The type ID of the event. | |
command | The action command string. | |
Description | Constructs an ActionEvent with the given characteristics. | |
public ActionEvent (Object source, int id, String command, int modifiers) | ||
Parameters | source | The object that generated the event. |
id | The type ID of the event. | |
command | The action command string. | |
modifiers | A combination of the key mask constants. | |
Description | Constructs an ActionEvent with the given characteristics. |
public String getActionCommand()
Returns | The action command string for this ActionEvent. |
Description | Generally the action command string is the label of the component that generated the event. Also, when localization is necessary, the action command string can provide a setting that does not get localized. |
public int getModifiers()
Returns | A combination of the key mask constants. |
Description | Returns the modifier keys that were held down when this action was performed. This enables you to perform special processing if, for example, the user holds down Shift while pushing a button. |
public String paramString()
Returns | String with current settings of ActionEvent. |
Overrides | AWTEvent.paramString() |
Description | Helper method for toString() to generate string of current settings. |
ActionListener, AWTEvent, String
Objects that implement the ActionListener interface can receive ActionEvent objects. Listeners must first register themselves with objects that produce events. When events occur, they are then automatically propagated to all registered listeners.
public abstract interface java.awt.event.ActionListener extends java.util.EventListener { // Interface Methods public abstract void actionPerformed (ActionEvent e); }
public abstract void actionPerformed (ActionEvent e)
Parameters | e | The action event that occurred. |
Description | Notifies the ActionListener that an event occurred. |
ActionEvent, AWTEventMulticaster, EventListener
AdjustmentEvents are generated by objects that implement the Adjustable interface. Scrollbar is one example of such an object.
public class java.awt.event.AdjustmentEvent extends java.awt.AWTEvent { // Constants public final static int ADJUSTMENT_FIRST; public final static int ADJUSTMENT_LAST; public final static int ADJUSTMENT_VALUE_CHANGED; public final static int BLOCK_DECREMENT; public final static int BLOCK_INCREMENT; public final static int TRACK; public final static int UNIT_DECREMENT; public final static int UNIT_INCREMENT; // Constructors public AdjustmentEvent (Adjustable source, int id, int type, int value); // Instance Methods public Adjustable getAdjustable(); public int getAdjustmentType(); public int getValue(); public String paramString(); }
public final static int ADJUSTMENT_FIRST
Specifies the beginning range of adjustment event ID values.
public final static int ADJUSTMENT_LAST
Specifies the ending range of adjustment event ID values.
Event type ID for value changed.
public final static int BLOCK_DECREMENT
Adjustment type for block decrement.
public final static int BLOCK_INCREMENT
Adjustment type for block increment.
public final static int TRACK
Adjustment type for tracking.
public final static int UNIT_DECREMENT
Adjustment type for unit decrement.
public final static int UNIT_INCREMENT
Adjustment type for unit increment.
public AdjustmentEvent (Adjustable source, int id, int type, int value)
Parameters | source | The object that generated the event. |
id | The event type ID of the event. | |
type | The type of adjustment event. | |
value | The value of the Adjustable object. | |
Description | Constructs an AdjustmentEvent with the given characteristics. |
public Adjustable getAdjustable()
Returns | The source of this event. |
public int getAdjustmentType()
Returns | One of the adjustment type constants. |
Description | The type will be BLOCK_DECREMENT, BLOCK_INCREMENT, TRACK, UNIT_DECREMENT, or UNIT_INCREMENT. |
public int getValue()
Returns | The new value of the Adjustable object. |
public String paramString()
Returns | String with current settings of the AdjustmentEvent. |
Overrides | AWTEvent.paramString() |
Description | Helper method for toString() to generate string of current settings. |
Adjustable, AdjustmentListener, AWTEvent, Scrollbar
Objects that implement the AdjustmentListener interface can receive AdjustmentEvent objects. Listeners must first register themselves with objects that produce events. When events occur, they are then automatically propagated to all registered listeners.
public abstract interface java.awt.event.AdjustmentListener extends java.util.Eventlistener { // Interface Methods public abstract void adjustmentValueChanged (AdjustmentEvent e); }
public abstract void adjustmentValueChanged (AdjustmentEvent e)
Parameters | e | The adjustment event that occurred. |
Description | Notifies the AdjustmentListener that an event occurred. |
AdjustmentEvent, AWTEventMulticaster, EventListener
ComponentAdapter is a class that implements the methods of ComponentListener with empty functions. It may be easier for you to extend ComponentAdapter, overriding only those methods you are interested in, than to implement ComponentListener and provide the empty functions yourself.
public abstract class java.awt.event.ComponentAdapter extends java.lang.Object implements java.awt.event.ComponentListener { // Instance Methods public void componentHidden (ComponentEvent e); public void componentMoved (ComponentEvent e); public void componentResized (ComponentEvent e); public void componentShown (ComponentEvent e); }
public void componentHidden (ComponentEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when a component is hidden. |
public void componentMoved (ComponentEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when a component is moved. |
public void componentResized (ComponentEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when a component is resized. |
public void componentShown (ComponentEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when a component is shown. |
Component, ComponentEvent, ComponentListener
Component events are generated when a component is shown, hidden, moved, or resized. AWT automatically deals with component moves and resizing; these events are provided only for notification. Subclasses of ComponentEvent deal with other specific component-level events.
public class java.awt.event.ComponentEvent extends java.awt.AWTEvent { // Constants public final static int COMPONENT_FIRST; public final static int COMPONENT_HIDDEN; public final static int COMPONENT_LAST; public final static int COMPONENT_MOVED; public final static int COMPONENT_RESIZED; public final static int COMPONENT_SHOWN; // Constructors public ComponentEvent (Component source, int id); // Instance Methods public Component getComponent(); public String paramString(); }
public final static int COMPONENT_FIRST
Specifies the beginning range of component event ID values.
public final static int COMPONENT_HIDDEN
Event type ID indicating that the component was hidden.
public final static int COMPONENT_LAST
Specifies the ending range of component event ID values.
public final static int COMPONENT_MOVED
Event type ID indicating that the component was moved.
public final static int COMPONENT_RESIZED
Event type ID indicating that the component was resized.
public final static int COMPONENT_SHOWN
Event type ID indicating that the component was shown.
public ComponentEvent (Component source, int id)
Parameters | source | The object that generated the event. |
id | The event type ID of the event. | |
Description | Constructs a ComponentEvent with the given characteristics. |
public Component getComponent()
Returns | The source of this event. |
public String paramString()
Returns | String with current settings of the ComponentEvent. |
Overrides | AWTEvent.paramString() |
Description | Helper method for toString() to generate string of current settings. |
AWTEvent, Component, ComponentAdapter, ComponentListener, ContainerEvent, FocusEvent, InputEvent, PaintEvent, WindowEvent
Objects that implement the ComponentListener interface can receive ComponentEvent objects. Listeners must first register themselves with objects that produce events. When events occur, they are then automatically propagated to all registered listeners.
public abstract interface java.awt.event.ComponentListener extends java.util.EventListener { // Instance Methods public abstract void componentHidden (ComponentEvent e); public abstract void componentMoved (ComponentEvent e); public abstract void componentResized (ComponentEvent e); public abstract void componentShown (ComponentEvent e); }
public abstract void componentHidden (ComponentEvent e)
Parameters | e | The component event that occurred. |
Description | Notifies the ComponentListener that a component was hidden. |
public abstract void componentMoved (ComponentEvent e)
Parameters | e | The component event that occurred. |
Description | Notifies the ComponentListener that a component was moved. |
public abstract void componentResized (ComponentEvent e)
Parameters | e | The component event that occurred. |
Description | Notifies the ComponentListener that a component was resized. |
public abstract void componentShown (ComponentEvent e)
Parameters | e | The component event that occurred. |
Description | Notifies the ComponentListener that a component was shown. |
AWTEventMulticaster, ComponentAdapter, ComponentEvent, EventListener
The ContainerAdapter class implements the methods of ContainerListener with empty functions. It may be easier for you to extend ContainerAdapter, overriding only those methods you are interested in, than to implement ContainerListener and provide the empty functions yourself.
public abstract class java.awt.event.ContainerAdapter extends java.lang.Object implements java.awt.event.ContainerListener { // Instance Methods
public void componentAdded (ContainerEvent e); public void componentRemoved (ContainerEvent e); }
public void componentAdded (ComponentEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when a component is added to a container. |
public void componentRemoved (ComponentEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when a component is removed from a container. |
ContainerEvent, ContainerListener
Container events are fired off when a component is added to or removed from a container. The AWT automatically deals with adding components to containers; these events are provided only for notification.
public class java.awt.event.ContainerEvent extends java.awt.event.ComponentEvent { // Constants public final static int COMPONENT_ADDED; public final static int COMPONENT_REMOVED; public final static int CONTAINER_FIRST; public final static int CONTAINER_LAST; // Constructors public ContainerEvent (Component source, int id, Component child); // Instance Methods
public Component getChild(); public Container getContainer(); public String paramString(); }
public final static int COMPONENT_ADDED
Event type ID indicating that a component was added to a container.
public final static int CONTAINER_FIRST
Specifies the beginning range of container event ID values.
public final static int CONTAINER_LAST
Specifies the ending range of container event ID values.
public final static int COMPONENT_REMOVED
Event type ID indicating that a component was removed from a container.
public ContainerEvent (Component source, int id, Component child)
Parameters | source | The object that generated the event. |
id | The event type ID of the event. | |
child | The component that was added or removed. | |
Description | Constructs a ContainerEvent with the given characteristics. |
public Component getChild()
Returns | The component that is being added or removed. |
public Container getContainer()
Returns | The container for this event. |
public String paramString()
Returns | String with current settings of the ContainerEvent. |
Overrides | ComponentEvent.paramString() |
Description | Helper method for toString() to generate string of current settings. |
Component, ComponentEvent, Container, ContainerAdapter, ContainerListener
Objects that implement the ContainerListener interface can receive ContainerEvent objects. Listeners must first register themselves with objects that produce events. When events occur, they are then automatically propagated to all registered listeners.
public abstract interface java.awt.event.ContainerListener extends java.util.EventListener { // Instance Methods public abstract void componentAdded (ContainerEvent e); public abstract void componentRemoved (ContainerEvent e); }
public abstract void componentAdded (ContainerEvent e)
Parameters | e | The event that occurred. |
Description | Notifies the ContainerListener that a component has been added to the container. |
public abstract void componentRemoved (ContainerEvent e)
Parameters | e | The event that occurred. |
Description | Notifies the ContainerListener that a component has been removed from the container. |
ContainerAdapter, ContainerEvent, EventListener
The FocusAdapter class implements the methods of FocusListener with empty functions. It may be easier for you to extend FocusAdapter, overriding only those methods you are interested in, than to implement FocusListener and provide the empty functions yourself.
public abstract class java.awt.event.FocusAdapter extends java.lang.Object implements java.awt.event.FocusListener { // Instance Methods public void focusGained (FocusEvent e); public void focusLost (FocusEvent e); }
public void focusGained (FocusEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when a component gains focus. |
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when a component loses focus. |
FocusEvent, FocusListener
Focus events are generated when a component gets or loses input focus. Focus events come in two flavors, permanent and temporary. Permanent focus events occur with explicit focus changes. For example, when the user tabs through components, this causes permanent focus events. An example of a temporary focus event is when a component loses focus as its containing window is deactivated.
public class java.awt.event.FocusEvent extends java.awt.event.ComponentEvent { // Constants public final static int FOCUS_FIRST; public final static int FOCUS_GAINED; public final static int FOCUS_LAST; public final static int FOCUS_LOST; // Constructors public FocusEvent (Component source, int id); public FocusEvent (Component source, int id, boolean temporary); // Instance Methods public boolean isTemporary(); public String paramString(); }
public final static int FOCUS_FIRST
Specifies the beginning range of focus event ID values.
public final static int FOCUS_GAINED
Event type ID indicating that the component gained the input focus.
public final static int FOCUS_LAST
Specifies the ending range of focus event ID values.
public final static int FOCUS_LOST
Event type ID indicating that the component lost the input focus.
public FocusEvent (Component source, int id)
Parameters | source | The object that generated the event. |
id | The event type ID of the event. | |
Description | Constructs a non-temporary FocusEvent with the given characteristics. | |
public FocusEvent (Component source, int id, boolean temporary) | ||
Parameters | source | The object that generated the event. |
id | The event type ID of the event. | |
temporary | A flag indicating whether this is a temporary focus event. | |
Description | Constructs a FocusEvent with the given characteristics. |
public boolean isTemporary()
Returns | true if this is a temporary focus event; false otherwise. |
public String paramString()
Returns | String with current settings of the FocusEvent. |
Overrides | ComponentEvent.paramString() |
Description | Helper method for toString() to generate string of current settings. |
Component, ComponentEvent, FocusAdapter, FocusListener
Objects that implement the FocusListener interface can receive FocusEvent objects. Listeners must first register themselves with objects that produce events. When events occur, they are then automatically propagated to all registered listeners.
public abstract interface java.awt.event.FocusListener extends java.util.EventListener { // Instance Methods public abstract void focusGained (FocusEvent e); public abstract void focusLost (FocusEvent e); }
public abstract void focusGained (FocusEvent e)
Parameters | e | The component event that occurred. |
Description | Notifies the FocusListener that a component gained the input focus. |
public abstract void focusLost (FocusEvent e)
Parameters | e | The component event that occurred. |
Description | Notifies the FocusListener that a component lost the input focus. |
AWTEventMulticaster, EventListener, FocusAdapter, FocusEvent
InputEvent is the root class for representing user input events. Input events are passed to listeners before the event source processes them. If one of the listeners consumes an event by using consume(), the event will not be processed by the event source peer.
public abstract class java.awt.event.InputEvent extends java.awt.event.ComponentEvent { // Constants public final static int ALT_MASK; public final static int BUTTON1_MASK; public final static int BUTTON2_MASK; public final static int BUTTON3_MASK; public final static int CTRL_MASK; public final static int META_MASK; public final static int SHIFT_MASK; // Instance Methods public void consume(); public int getModifiers(); public long getWhen(); public boolean isAltDown(); public boolean isConsumed(); public boolean isControlDown(); public boolean isMetaDown(); public boolean isShiftDown(); }
public final static int ALT_MASK
The ALT key mask. ORed with other masks to form modifiers setting of event.
public final static int BUTTON1_MASK
The mouse button 1 key mask. ORed with other masks to form modifiers setting of event.
public final static int BUTTON2_MASK
The mouse button 2 key mask. ORed with other masks to form modifiers setting of event. This constant is identical to ALT_MASK.
public final static int BUTTON3_MASK
The mouse button 3 key mask. ORed with other masks to form modifiers setting of event. This constant is identical to ALT_MASK.
public final static int CTRL_MASK
The Control key mask. ORed with other masks to form modifiers setting of event.
public final static int META_MASK
The Meta key mask. ORed with other masks to form modifiers setting of event.
public final static int SHIFT_MASK
The Shift key mask. ORed with other masks to form modifiers setting of event.
public void consume()
Description | A consumed event will not be delivered to its source for default processing. |
public int getModifiers()
Returns | The modifier flags, a combination of the _MASK constants. |
Description | Use this method to find out what modifier keys were pressed when an input event occurred. |
public long getWhen()
Returns | The time at which this event occurred. |
Description | The time of the event is returned as the number of milliseconds since the epoch (00:00:00 UTC, January 1, 1970). Conveniently, java.util.Date has a constructor that accepts such values. |
public boolean isAltDown()
Returns | true if the Alt key was pressed; false otherwise. |
public boolean isConsumed()
Returns | true if the event has been consumed; false otherwise. |
public boolean isControlDown()
Returns | true if the Control key was pressed; false otherwise. |
public boolean isMetaDown()
Returns | true if the Meta key was pressed; false otherwise. |
public boolean isShiftDown()
Returns | true if the Shift key was pressed; false otherwise. |
ComponentEvent, KeyEvent, MouseEvent
ItemEvents are generated by objects that implement the ItemSelectable interface. Choice is one example of such an object.
public class java.awt.event.ItemEvent extends java.awt.AWTEvent { // Constants public final static int DESELECTED; public final static int ITEM_FIRST; public final static int ITEM_LAST; public final static int ITEM_STATE_CHANGED; public final static int SELECTED; // Constructors public ItemEvent (ItemSelectable source, int id, Object item, int stateChange); // Instance Methods public Object getItem(); public ItemSelectable getItemSelectable(); public int getStateChange(); public String paramString(); }
public final static int DESELECTED
Indicates that an item was deselected.
public final static int ITEM_FIRST
Specifies the beginning range of item event ID values.
public final static int ITEM_LAST
Specifies the ending range of item event ID values.
public final static int ITEM_STATE_CHANGED
An event type indicating that an item was selected or deselected.
public final static int SELECTED
Indicates that an item was selected.
public ItemEvent (ItemSelectable source, int id, Object item, int stateChange)
Parameters | source | The object that generated the event. |
id | The type ID of the event. | |
item | The item whose state is changing. | |
stateChange | Either SELECTED or DESELECTED. | |
Description | Constructs an ItemEvent with the given characteristics. |
public Object getItem()
Returns | The item pertaining to this event. |
Description | Returns the item whose changed state triggered this event. |
public ItemSelectable getItemSelectable()
Returns | The source of this event. |
Description | Returns an object that implements the ItemSelectable interface. |
public int getStateChange()
Returns | The change in state that triggered this event. The new state is returned. |
Description | This method will return SELECTED or DESELECTED. |
public String paramString()
Returns | String with current settings of ItemEvent. |
Overrides | AWTEvent.paramString() |
Description | Helper method for toString() to generate string of current settings. |
AWTEvent, ItemSelectable, ItemListener
Objects that implement the ItemListener interface can receive ItemEvent objects. Listeners must first register themselves with objects that produce events. When events occur, they are then automatically propagated to all registered listeners.
public abstract interface java.awt.event.ItemListener extends java.util.EventListener { // Interface Methods public abstract void itemStateChanged (ItemEvent e); }
public abstract void itemStateChanged (ItemEvent e)
Parameters | e | The item event that occurred. |
Description | Notifies the ItemListener that an event occurred. |
AWTEventMulticaster, EventListener, ItemEvent
The KeyAdapter class implements the methods of KeyListener with empty functions. It may be easier for you to extend KeyAdapter, overriding only those methods you are interested in, than to implement KeyListener and provide the empty functions yourself.
public abstract class java.awt.event.KeyAdapter extends java.lang.Object implements java.awt.event.KeyListener { // Instance Methods public void keyPressed (KeyEvent e); public void keyReleased (KeyEvent e); public void keyTyped (KeyEvent e); }
public void keyPressed (KeyEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when a key is pressed. |
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when a pressed key is released. |
public void keyTyped (KeyEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when a key has been pressed and released. |
KeyEvent, KeyListener
Key events are generated when the user types on the keyboard.
public class java.awt.event.KeyEvent extends java.awt.event.InputEvent { // Constants public final static int CHAR_UNDEFINED; public final static int KEY_FIRST; public final static int KEY_LAST; public final static int KEY_PRESSED; public final static int KEY_RELEASED; public final static int KEY_TYPED; public final static int VK_0; public final static int VK_1; public final static int VK_2; public final static int VK_3; public final static int VK_4; public final static int VK_5; public final static int VK_6; public final static int VK_7; public final static int VK_8; public final static int VK_9; public final static int VK_A; public final static int VK_ACCEPT; public final static int VK_ADD;
public final static int VK_ALT; public final static int VK_B; public final static int VK_BACK_QUOTE; public final static int VK_BACK_SLASH; public final static int VK_BACK_SPACE; public final static int VK_C; public final static int VK_CANCEL; public final static int VK_CAPS_LOCK; public final static int VK_CLEAR; public final static int VK_CLOSE_BRACKET; public final static int VK_COMMA; public final static int VK_CONTROL; public final static int VK_CONVERT; public final static int VK_D; public final static int VK_DECIMAL; public final static int VK_DELETE; public final static int VK_DIVIDE; public final static int VK_DOWN; public final static int VK_E; public final static int VK_END; public final static int VK_ENTER; public final static int VK_EQUALS; public final static int VK_ESCAPE; public final static int VK_F; public final static int VK_F1; public final static int VK_F2; public final static int VK_F3; public final static int VK_F4; public final static int VK_F5; public final static int VK_F6; public final static int VK_F7; public final static int VK_F8; public final static int VK_F9; public final static int VK_F10; public final static int VK_F11; public final static int VK_F12; public final static int VK_FINAL; public final static int VK_G; public final static int VK_H; public final static int VK_HELP; public final static int VK_HOME; public final static int VK_I; public final static int VK_INSERT; public final static int VK_J; public final static int VK_K; public final static int VK_KANA; public final static int VK_KANJI; public final static int VK_L; public final static int VK_LEFT;
public final static int VK_M; public final static int VK_META; public final static int VK_MODECHANGE; public final static int VK_MULTIPLY; public final static int VK_N; public final static int VK_NONCONVERT; public final static int VK_NUM_LOCK; public final static int VK_NUMPAD0; public final static int VK_NUMPAD1; public final static int VK_NUMPAD2; public final static int VK_NUMPAD3; public final static int VK_NUMPAD4; public final static int VK_NUMPAD5; public final static int VK_NUMPAD6; public final static int VK_NUMPAD7; public final static int VK_NUMPAD8; public final static int VK_NUMPAD9; public final static int VK_O; public final static int VK_OPEN_BRACKET; public final static int VK_P; public final static int VK_PAGE_DOWN; public final static int VK_PAGE_UP; public final static int VK_PAUSE; public final static int VK_PERIOD; public final static int VK_PRINTSCREEN; public final static int VK_Q; public final static int VK_QUOTE; public final static int VK_R; public final static int VK_RIGHT; public final static int VK_S; public final static int VK_SCROLL_LOCK; public final static int VK_SEMICOLON; public final static int VK_SEPARATER; public final static int VK_SHIFT; public final static int VK_SLASH; public final static int VK_SPACE; public final static int VK_SUBTRACT; public final static int VK_T; public final static int VK_TAB; public final static int VK_U; public final static int VK_UNDEFINED; public final static int VK_UP; public final static int VK_V; public final static int VK_W; public final static int VK_X; public final static int VK_Y; public final static int VK_Z; // Constructors
public KeyEvent (Component source, int id, long when, int modifiers, int keyCode, char keyChar); // Class Methods public static String getKeyModifiersText(int modifiers); public static String getKeyText(int keyCode); // Instance Methods public char getKeyChar(); public int getKeyCode(); public boolean isActionKey(); public String paramString(); public void setKeyChar (char keyChar); public void setKeyCode (int keyCode); public void setModifiers (int modifiers); }
public final static int CHAR_UNDEFINED
This constant is used for key presses have that no associated character.
public final static int KEY_FIRST
Specifies the beginning range of key event ID values.
public final static int KEY_LAST
Specifies the ending range of key event ID values.
public final static int KEY_PRESSED
An event ID type for a key press.
public final static int KEY_RELEASED
An event ID type for a key release.
An event ID type for a typed key (a press and a release).
public final static int VK_0
The 0 key.
public final static int VK_1
The 1 key.
public final static int VK_2
The 2 key.
public final static int VK_3
The 3 key.
public final static int VK_4
The 4 key.
public final static int VK_5
The 5 key.
public final static int VK_6
The 6 key.
public final static int VK_7
The 7 key.
public final static int VK_8
The 8 key.
public final static int VK_9
The 9 key.
public final static int VK_A
The ‘a’ key.
public final static int VK_ACCEPT
This constant is used for Asian keyboards.
public final static int VK_ADD
The plus (+) key on the numeric keypad.
public final static int VK_ALT
The Alt key.
public final static int VK_B
The ‘b’ key.
public final static int VK_BACK_QUOTE
The backquote (‘) key.
public final static int VK_BACK_SLASH
The backslash key.
public final static int VK_BACK_SPACE
The Backspace key.
public final static int VK_C
The ‘c’ key.
public final static int VK_CANCEL
The Cancel key.
public final static int VK_CAPS_LOCK
The Caps Lock key.
public final static int VK_CLEAR
The Clear key.
public final static int VK_CLOSE_BRACKET
The close bracket ‘]’ key.
public final static int VK_COMMA
The comma (,) key.
public final static int VK_CONTROL
The Control key.
public final static int VK_CONVERT
This constant is used for Asian keyboards.
public final static int VK_D
The ‘d’ key.
public final static int VK_DECIMAL
The decimal (.) key on the numeric keypad.
public final static int VK_DELETE
The Delete key.
public final static int VK_DIVIDE
The divide (/) key on the numeric keypad.
public final static int VK_DOWN
The Down arrow key.
public final static int VK_E
The ‘e’ key.
public final static int VK_END
The End key.
public final static int VK_ENTER
The Enter key.
public final static int VK_ EQUALS
The equals (=) key.
public final static int VK_ESCAPE
The Escape key.
public final static int VK_F
The ‘f’ key.
public final static int VK_F1
The F1 key.
public final static int VK_F2
The F2 key.
public final static int VK_F3
The F3 key.
public final static int VK_F4
The F4 key.
public final static int VK_F5
The F5 key.
public final static int VK_F6
The F6 key.
public final static int VK_F7
The F7 key.
public final static int VK_F8
The F8 key.
public final static int VK_F9
The F9 key.
public final static int VK_F10
The F10 key.
public final static int VK_F11
The F11 key.
public final static int VK_F12
The F12 key.
public final static int VK_FINAL
This constant is used for Asian keyboards.
public final static int VK_G
The ‘g’ key.
public final static int VK_H
The ‘h’ key.
public final static int VK_HELP
The Help key.
public final static int VK_HOME
The Home key.
public final static int VK_I
The ‘i’ key.
public final static int VK_INSERT
The Insert key.
public final static int VK_J
The ‘j’ key.
public final static int VK_K
The ‘k’ key.
public final static int VK_KANA
This constant is used for Asian keyboards.
public final static int VK_KANJI
This constant is used for Asian keyboards.
public final static int VK_L
The ‘l’ key.
public final static int VK_LEFT
The Left arrow key.
public final static int VK_M
The ‘m’ key.
public final static int VK_MODECHANGE
This constant is used for Asian keyboards.
public final static int VK_META
The Meta key.
public final static int VK_MULTIPLY
The * key on the numeric keypad.
public final static int VK_N
The ‘n’ key.
public final static int VK_NONCONVERT
This constant is used for Asian keyboards.
public final static int VK_NUM_LOCK
The Num Lock key.
public final static int VK_NUMPAD0
The 0 key on the numeric keypad.
public final static int VK_NUMPAD1
The 1 key on the numeric keypad.
public final static int VK_NUMPAD2
The 2 key on the numeric keypad.
public final static int VK_NUMPAD3
The 3 key on the numeric keypad.
public final static int VK_NUMPAD4
The 4 key on the numeric keypad.
public final static int VK_NUMPAD5
The 5 key on the numeric keypad.
public final static int VK_NUMPAD6
The 6 key on the numeric keypad.
public final static int VK_NUMPAD7
The 7 key on the numeric keypad.
public final static int VK_NUMPAD8
The 8 key on the numeric keypad.
public final static int VK_NUMPAD9
The 9 key on the numeric keypad.
public final static int VK_O
The ‘o’ key.
public final static int VK_OPEN_BRACKET
The open bracket ‘[‘ key.
public final static int VK_P
The ‘p’ key.
public final static int VK_PAGE_DOWN
The Page Down key.
public final static int VK_PAGE_UP
The Page Up key.
public final static int VK_PAUSE
The Pause key.
public final static int VK_PERIOD
The period (.) key.
public final static int VK_PRINTSCREEN
The Print Screen key.
public final static int VK_Q
The ‘q’ key.
public final static int VK_QUOTE
The quotation mark (”) key.
public final static int VK_R
The ‘r’ key.
public final static int VK_RIGHT
The Right arrow key.
public final static int VK_S
The ‘s’ key.
public final static int VK_SCROLL_LOCK
The Scroll Lock key.
public final static int VK_SEMICOLON
The semicolon (;) key.
public final static int VK_SEPARATER
The numeric separator key on the numeric keypad (i.e., the locale-dependent key used to separate groups of digits). A misspelling of VK_SEPARATOR.
public final static int VK_SHIFT
The Shift key.
public final static int VK_SLASH
The slash (/) key.
public final static int VK_SPACE
The space key.
public final static int VK_SUBTRACT
The subtract (−) key on the numeric keypad.
public final static int VK_T
The ‘t’ key.
public final static int VK_TAB
The Tab key.
public final static int VK_U
The ‘u’ key.
public final static int VK_UNDEFINED
An undefined key.
public final static int VK_UP
The Up arrow key.
public final static int VK_V
The ‘v’ key.
public final static int VK_W
The ‘w’ key.
public final static int VK_X
The ‘x’ key.
public final static int VK_Y
The ‘y’ key.
public final static int VK_Z
The ‘z’ key.
public KeyEvent (Component source, int id, long when, int modifiers, int keyCode, char keyChar)
Parameters | source | The object that generated the event. |
id | The event type ID of the event. | |
when | When the event occurred, in milliseconds from the epoch. | |
modifiers | What modifier keys were pressed with this key. | |
keyCode | The code of the key. | |
keyChar | The character for this key. | |
Description | Constructs a KeyEvent with the given characteristics. |
public static String getKeyModifiersText(int modifiers)
Parameters | modifiers | One or more modifier keys. |
Returns | A string describing the modifiers. |
public static String getKeyText(int keyCode)
Parameters | keyCode | One of the key codes. |
Returns | A string describing the given key. |
public char getKeyChar()
Returns | The character corresponding to this event. KEY_TYPED events have characters. |
public int getKeyCode()
Returns | The integer key code corresponding to this event. This will be one of the constants defined above. KEY_PRESSED and KEY_RELEASED events have codes. Key codes are virtual keys, not actual. Pressing the ‘a’ key is identical to ‘A’, but has different modifiers. Same for ‘/’ and ‘?’ on a standard keyboard. |
public boolean isActionKey()
Returns | true if this event is for one of the action keys; false otherwise. |
Description | In general, an action key is a key that causes an action but has no printing equivalent. The action keys are the function keys, the arrow keys, Caps Lock, End, Home, Insert, Num Lock, Pause, Page Down, Page Up, Print Screen, and Scroll Lock. They do not generate a KEY_TYPED event, only KEY_PRESSED and KEY_RELEASED. |
public String paramString()
Returns | A string with current settings of the KeyEvent. |
Overrides | ComponentEvent.paramString() |
Description | Helper method for toString() to generate string of current settings. |
public void setKeyChar(char keyChar)
Parameters | keyChar | The new key character. |
Description | Sets the character code of this KeyEvent. |
public void setKeyCode (int keyCode)
Parameters | keyCode | The new key code. |
Description | Sets the key code of this KeyEvent. |
public void setModifiers (int modifiers)
Parameters | modifiers | The new modifiers. |
Description | This is a combination of the mask constants defined in java.awt.event.InputEvent. |
Component, ComponentEvent, InputEvent, KeyAdapter, KeyListener
Objects that implement the KeyListener interface can receive KeyEvent objects. Listeners must first register themselves with objects that produce events. When events occur, they are then automatically propagated to all registered listeners.
public abstract interface java.awt.event.KeyListener extends java.util.EventListener { // Instance Methods public abstract void keyPressed (KeyEvent e); public abstract void keyReleased (KeyEvent e); public abstract void keyTyped (KeyEvent e); }
public abstract void keyPressed (KeyEvent e)
Parameters | e | The key event that occurred. |
Description | Notifies the KeyListener that a key was pressed. |
public abstract void keyReleased (KeyEvent e)
Parameters | e | The key event that occurred. |
Description | Notifies the KeyListener that a key was released. |
public abstract void keyTyped (KeyEvent e)
Parameters | e | The key event that occurred. |
Description | Notifies the KeyListener that a key was typed (pressed and released). |
AWTEventMulticaster, EventListener, KeyEvent, KeyListener
The MouseAdapter class implements the methods of MouseListener with empty functions. It may be easier for you to extend MouseAdapter, overriding only those methods you are interested in, than to implement MouseListener and provide the empty functions yourself.
public abstract class java.awt.event.MouseAdapter extends java.lang.Object implements java.awt.event.MouseListener { // Instance Methods public void mouseClicked (MouseEvent e); public void mouseEntered (MouseEvent e); public void mouseExited (MouseEvent e); public void mousePressed (MouseEvent e); public void mouseReleased (MouseEvent e); }
public void mouseClicked (MouseEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when the mouse button is clicked (pressed and released). |
public void mouseEntered (MouseEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when the user moves the mouse cursor into a component. |
public void mouseExited (MouseEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when the moves the mouse cursor out of a component. |
public void mousePressed (MouseEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when the mouse button is pressed. |
public void mouseReleased (MouseEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when the mouse button is released. |
MouseEvent, MouseListener
Mouse events are generated when the user moves and clicks the mouse.
public class java.awt.event.MouseEvent extends java.awt.event.InputEvent { // Constants public final static int MOUSE_CLICKED; public final static int MOUSE_DRAGGED; public final static int MOUSE_ENTERED; public final static int MOUSE_EXITED; public final static int MOUSE_FIRST; public final static int MOUSE_LAST; public final static int MOUSE_MOVED; public final static int MOUSE_PRESSED; public final static int MOUSE_RELEASED; // Constructors public MouseEvent (Component source, int id, long when, int modifiers, int x, int y, int clickCount, boolean popupTrigger); // Instance Methods public int getClickCount(); public synchronized Point getPoint(); public int getX(); public int getY(); public boolean isPopupTrigger(); public String paramString(); public synchronized void translatePoint (int x, int y); }
public final static int MOUSE_CLICKED
An event type ID indicating a mouse click.
An event type ID indicating a mouse move with the button held down.
public final static int MOUSE_ENTERED
An event type ID indicating that a mouse entered a component.
public final static int MOUSE_EXITED
An event type ID indicating that a mouse left a component.
public final static int MOUSE_FIRST
Specifies the beginning range of mouse event ID values.
public final static int MOUSE_LAST
Specifies the ending range of mouse event ID values.
public final static int MOUSE_MOVED
An event type ID indicating a mouse move.
public final static int MOUSE_PRESSED
An event type ID indicating a mouse button press.
public final static int MOUSE_RELEASED
An event type ID indicating a mouse button release.
public MouseEvent (Component source, int id, long when, int modifiers, int x, int y, int clickCount, boolean popupTrigger)
public int getClickCount()
Returns | The number of consecutive mouse button clicks for this event. |
public synchronized Point getPoint()
Returns | The location where the event happened. |
public int getX()
Returns | The horizontal location where the event happened. |
public int getY()
Returns | The vertical location where the event happened. |
public boolean isPopupTrigger()
Returns | Returns true if this event is the popup menu event for the runtime system. |
public String paramString()
Returns | String with current settings of the MouseEvent. |
Overrides | ComponentEvent.paramString() |
Description | Helper method for toString() to generate string of current settings. |
public synchronized void translatePoint (int x, int y)
Parameters | x | The horizontal amount of translation. |
y | The vertical amount of translation. | |
Description | Translates the location of the event by the given amounts. |
Component, ComponentEvent, InputEvent, MouseAdapter, MouseListener, Point
Objects that implement the MouseListener interface can receive non-motion oriented MouseEvent objects. Listeners must first register themselves with objects that produce events. When events occur, they are then automatically propagated to all registered listeners.
public abstract interface java.awt.event.MouseListener extends java.util.EventListener { // Instance Methods public abstract void mouseClicked (MouseEvent e); public abstract void mouseEntered (MouseEvent e); public abstract void mouseExited (MouseEvent e); public abstract void mousePressed (MouseEvent e); public abstract void mouseReleased (MouseEvent e); }
public abstract void mouseClicked (MouseEvent e)
Parameters | e | The key event that occurred. |
Description | Notifies the MouseListener that the mouse button was clicked (pressed and released). |
public abstract void mouseEntered (MouseEvent e)
Parameters | e | The key event that occurred. |
Description | Notifies the MouseListener that the mouse cursor has been moved into a component's coordinate space. |
public abstract void mouseExited (MouseEvent e)
Parameters | e | The key event that occurred. |
Description | Notifies the MouseListener that the mouse cursor has been moved out of a component's coordinate space. |
public abstract void mousePressed (MouseEvent e)
Parameters | e | The key event that occurred. |
Description | Notifies the MouseListener that the mouse button was pressed. |
public abstract void mouseReleased (MouseEvent e)
Parameters | e | The key event that occurred. |
Description | Notifies the MouseListener that the mouse button was released. |
EventListener, MouseAdapter, MouseEvent
The MouseMotionAdapter class implements the methods of MouseMotionListener with empty functions. It may be easier for you to extend MouseMotionAdapter, overriding only those methods you are interested in, than to implement MouseMotionListener and provide the empty functions yourself.
public abstract class java.awt.event.MouseMotionAdapter extends java.lang.Object implements java.awt.event.MouseMotionListener { // Instance Methods public void mouseDragged (MouseEvent e); public void mouseMoved (MouseEvent e); }
public void mouseDragged (MouseEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when the mouse is dragged. |
public void mouseEntered (MouseEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when the mouse moves. |
MouseEvent, MouseMotionListener
Objects that implement the MouseMotionListener interface can receive motionoriented MouseEvent objects. Listeners must first register themselves with objects that produce events. When events occur, they are automatically propagated to all registered listeners.
public abstract interface java.awt.event.MouseMotionListener extends java.util.EventListener { // Instance Methods public abstract void mouseDragged (MouseEvent e); public abstract void mouseMoved (MouseEvent e); }
public abstract void mouseDragged (MouseEvent e)
Parameters | e | The key event that occurred. |
Description | Notifies the MouseMotionListener that the mouse has been dragged. |
public abstract void mouseMoved (MouseEvent e)
Parameters | e | The key event that occurred. |
Description | Notifies the MouseMotionListener that the mouse has been moved. |
AWTEventMulticaster, EventListener, MouseEvent, MouseMotionAdapter
The PaintEvent class represents the paint and update operations that the AWT performs on components. There is no PaintListener interface, so the only way to catch these events is to override paint(Graphics) and update(Graphics) in Component. This class exists so that paint events will get serialized properly.
public class java.awt.event.PaintEvent extends java.awt.event.ComponentEvent { // Constants public final static int PAINT; public final static int PAINT_FIRST; public final static int PAINT_LAST; public final static int UPDATE; // Constructor public PaintEvent (Component source, int id, Rectangle updateRect); // Instance Methods public Rectangle getUpdateRect(); public String paramString(); public void setUpdateRect (Rectangle updateRect); }
public class java.awt.event.PaintEvent extends java.awt.event.ComponentEvent { // Constants public final static int PAINT; public final static int PAINT_FIRST; public final static int PAINT_LAST; public final static int UPDATE; //Constructor public PaintEvent (Component source, int id, Rectangle updateRect); // Instance Methods public Rectangle getUpdateRect(); public String paramString(); public void setUpdateRect (Rectangle updateRect); }
public final static int PAINT
The paint event type.
public final static int PAINT_FIRST
Specifies the beginning range of paint event ID values.
public final static int PAINT_LAST
Specifies the ending range of paint event ID values.
public final static int UPDATE
The update event type.
public PaintEvent (Component source, ind id, Rectangle updateRect)
Parameters | source | The source of the event. |
id | The event type ID. | |
g | The rectangular area to paint. | |
Description | Constructs a PaintEvent with the given characteristics. |
public Rectangle getUpdateRect()
Returns | The rectangular area that needs painting. |
public String paramString()
Returns | String with current settings of the PaintEvent. |
Overrides | ComponentEvent.paramString() |
Description | Helper method for toString() to generate string of current settings. |
public void setUpdateRect (Rectangle updateRect)
Parameters | updateRect | The rectangular area to paint. |
Description | Changes the rectangular area that this PaintEvent will paint. |
Component, ComponentEvent, Graphics
Text events are generated by text components when their contents change, either programmatically or by a user typing.
public class java.awt.event.TextEvent extends java.awt.AWTEvent { // Constants public final static int TEXT_FIRST; public final static int TEXT_LAST; public final static int TEXT_VALUE_CHANGED; // Constructors public TextEvent (Object source, int id); // Instance Methods public String paramString(); }
public final static int TEXT_FIRST
Specifies the beginning range of text event ID values.
public final static int TEXT_LAST
Specifies the ending range of text event ID values.
public final static int TEXT_VALUE_CHANGED
The only text event type; it indicates that the contents of something have changed.
public TextEvent (Object source, int id)
Parameters | source | The object that generated the event. |
id | The type ID of the event. | |
Description | Constructs a TextEvent with the given characteristics. |
public String paramString()
Returns | String with current settings of the TextEvent. |
Overrides | AWTEvent.paramString() |
Description | Helper method for toString() to generate string of current settings. |
AWTEvent, TextListener
Objects that implement the TextListener interface can receive TextEvent objects. Listeners must first register themselves with objects that produce events. When events occur, they are then automatically propagated to all registered listeners.
public abstract interface java.awt.event.TextListener extends java.util.EventListener { // Interface Methods public abstract void textValueChanged (TextEvent e); }
public abstract void textValueChanged (TextEvent e)
Parameters | e | The text event that occurred. |
Description | Notifies the TextListener that an event occurred. |
AWTEventMulticaster, EventListener, TextEvent
The WindowAdapter class implements the methods of WindowListener with empty functions. It may be easier for you to extend WindowAdapter, overriding only those methods you are interested in, than to implement WindowListener and provide the empty functions yourself.
public abstract class java.awt.event.WindowAdapter extends java.lang.Object implements java.awt.event.WindowListener { // Instance Methods public void windowActivated (WindowEvent e); public void windowClosed (WindowEvent e); public void windowClosing (WindowEvent e); public void windowDeactivated (WindowEvent e); public void windowDeiconified (WindowEvent e); public void windowIconified (WindowEvent e); public void windowOpened (WindowEvent e); }
public void windowActivated (WindowEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when a window is activated. |
public void windowClosed (WindowEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when a window is closed. |
public void windowClosing (WindowEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when a window is in the process of closing. |
public void windowDeactivated (WindowEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when a window is deactivated. |
public void windowDeiconified (WindowEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when an iconified window is restored. |
public void windowIconified (WindowEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when a window is iconified (minimized). |
public void windowOpened (WindowEvent e)
Parameters | e | The event that has occurred. |
Description | Does nothing. Override this function to be notified when a window is opened. |
WindowEvent, WindowListener
Window events are generated when a window is opened, closed, iconified, or deiconified.
public class java.awt.event.WindowEvent extends java.awt.event.ComponentEvent { // Constants public final static int WINDOW_ACTIVATED; public final static int WINDOW_CLOSED; public final static int WINDOW_CLOSING; public final static int WINDOW_DEACTIVATED; public final static int WINDOW_DEICONIFIED; public final static int WINDOW_FIRST; public final static int WINDOW_ICONIFIED; public final static int WINDOW_LAST; public final static int WINDOW_OPENED; // Constructors public WindowEvent (Window source, int id); // Instance Methods public Window getWindow(); public String paramString();
}
public final static int WINDOW_ACTIVATED
Event type ID indicating the window has been activated, brought to the foreground.
public final static int WINDOW_CLOSED
Event type ID indicating the window has closed.
public final static int WINDOW_CLOSING
Event type ID indicating the window is closing.
public final static int WINDOW_DEACTIVATED
Event type ID indicating the window has been deactivated, placed in the background.
public final static int WINDOW_DEICONIFIED
Event type ID indicating the window has been restored from an iconified state.
public final static int WINDOW_FIRST
Specifies the beginning range of window event ID values.
public final static int WINDOW_ICONIFIED
Event type ID indicating the window has been iconified (minimized).
public final static int WINDOW_LAST
Specifies the ending range of window event ID values.
public final static int WINDOW_OPENED
Event type ID indicating the window has opened.
public WindowEvent (Window source, int id)
Parameters | source | The object that generated the event. |
id | The event type ID of the event. | |
Description | Constructs a WindowEvent with the given characteristics. |
public Window getWindow()
Returns | The window that generated this event. |
public String paramString()
Returns | String with current settings of the WindowEvent. |
Overrides | ComponentEvent.paramString() |
Description | Helper method for toString() to generate string of current settings. |
ComponentEvent, Window, WindowAdapter, WindowListener
Objects that implement the WindowListener interface can receive WindowEvent objects. Listeners must first register themselves with objects that produce events. When events occur, they are then automatically propagated to all registered listeners.
public abstract interface java.awt.event.WindowListener extends java.util.EventListener { // Instance Methods
public abstract void windowActivated (WindowEvent e); public abstract void windowClosed (WindowEvent e); public abstract void windowClosing (WindowEvent e); public abstract void windowDeactivated (WindowEvent e); public abstract void windowDeiconified (WindowEvent e); public abstract void windowIconified (WindowEvent e); public abstract void windowOpened (WindowEvent e); }
public abstract void windowActivated (WindowEvent e)
Parameters | e | The event that occurred. |
Description | Notifies the WindowListener that a window has been activated. |
public abstract void windowClosed (WindowEvent e)
Parameters | e | The event that occurred. |
Description | Notifies the WindowListener that a window has closed. |
public abstract void windowClosing (WindowEvent e)
Parameters | e | The event that occurred. |
Description | Notifies the WindowListener that a window is closing. |
public abstract void windowDeactivated (WindowEvent e)
Parameters | e | The event that occurred. |
Description | Notifies the WindowListener that a window has been deactivated. |
public abstract void windowDeiconified (WindowEvent e)
Parameters | e | The event that occurred. |
Description | Notifies the WindowListener that a window has been restored from an iconified state. |
public abstract void windowIconified (WindowEvent e)
Parameters | e | The event that occurred. |
Description | Notifies the WindowListener that a window has iconified (minimized). |
public abstract void windowOpened (WindowEvent e)
Parameters | e | The event that occurred. |
Description | Notifies the WindowListener that a window has opened. |
AWTEventMulticaster, EventListener, Window, WindowAdapter, WindowEvent
3.144.33.41