Class FocusEvent
- java.lang.Object
-
- java.util.EventObject
-
- java.awt.AWTEvent
-
- java.awt.event.ComponentEvent
-
- java.awt.event.FocusEvent
-
- All Implemented Interfaces:
- java.io.Serializable
public class FocusEvent extends ComponentEventA low-level event which indicates that a Component has gained or lost the input focus. This low-level event is generated by a Component (such as a TextField). The event is passed to everyFocusListener
orFocusAdapter
object which registered to receive such events using the Component'saddFocusListener
method. (FocusAdapter
objects implement theFocusListener
interface.) Each such listener object gets thisFocusEvent
when the event occurs.There are two levels of focus events: permanent and temporary. Permanent focus change events occur when focus is directly moved from one Component to another, such as through a call to requestFocus() or as the user uses the TAB key to traverse Components. Temporary focus change events occur when focus is temporarily lost for a Component as the indirect result of another operation, such as Window deactivation or a Scrollbar drag. In this case, the original focus state will automatically be restored once that operation is finished, or, for the case of Window deactivation, when the Window is reactivated. Both permanent and temporary focus events are delivered using the FOCUS_GAINED and FOCUS_LOST event ids; the level may be distinguished in the event using the isTemporary() method.
An unspecified behavior will be caused if the
id
parameter of any particularFocusEvent
instance is not in the range fromFOCUS_FIRST
toFOCUS_LAST
.- Since:
- 1.1
- See Also:
FocusAdapter
,FocusListener
, Tutorial: Writing a Focus Listener, Serialized Form
-
-
Fields Modifier and Type Field and Description ACTION_EVENT_MASK The event mask for selecting action events.ADJUSTMENT_EVENT_MASK The event mask for selecting adjustment events.COMPONENT_EVENT_MASK The event mask for selecting component events.COMPONENT_FIRST The first number in the range of ids used for component events.COMPONENT_HIDDEN This event indicates that the component was rendered invisible.COMPONENT_LAST The last number in the range of ids used for component events.COMPONENT_MOVED This event indicates that the component's position changed.COMPONENT_RESIZED This event indicates that the component's size changed.COMPONENT_SHOWN This event indicates that the component was made visible.consumed Controls whether or not the event is sent back down to the peer once the source has processed it - false means it's sent to the peer; true means it's not.CONTAINER_EVENT_MASK The event mask for selecting container events.FOCUS_EVENT_MASK The event mask for selecting focus events.FOCUS_FIRST The first number in the range of ids used for focus events.FOCUS_GAINED This event indicates that the Component is now the focus owner.FOCUS_LAST The last number in the range of ids used for focus events.FOCUS_LOST This event indicates that the Component is no longer the focus owner.HIERARCHY_BOUNDS_EVENT_MASK The event mask for selecting hierarchy bounds events.HIERARCHY_EVENT_MASK The event mask for selecting hierarchy events.id The event's id.INPUT_METHOD_EVENT_MASK The event mask for selecting input method events.INVOCATION_EVENT_MASK The event mask for selecting invocation events.ITEM_EVENT_MASK The event mask for selecting item events.KEY_EVENT_MASK The event mask for selecting key events.MOUSE_EVENT_MASK The event mask for selecting mouse events.MOUSE_MOTION_EVENT_MASK The event mask for selecting mouse motion events.MOUSE_WHEEL_EVENT_MASK The event mask for selecting mouse wheel events.PAINT_EVENT_MASK The event mask for selecting paint events.RESERVED_ID_MAX The maximum value for reserved AWT event IDs.source The object on which the Event initially occurred.TEXT_EVENT_MASK The event mask for selecting text events.WINDOW_EVENT_MASK The event mask for selecting window events.WINDOW_FOCUS_EVENT_MASK The event mask for selecting window focus events.WINDOW_STATE_EVENT_MASK The event mask for selecting window state events.
-
Methods Modifier and Type Method and Description consume Consumes this event, if this event can be consumed.getComponent Returns the originator of the event.getID Returns the event type.getOppositeComponent Returns the other Component involved in this focus change.getSource The object on which the Event initially occurred.isConsumed Returns whether this event has been consumed.isTemporary Identifies the focus change event as temporary or permanent.paramString Returns a parameter string identifying this event.setSource Retargets an event to a new source.toString Returns a String representation of this object.
-