All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class java.awt.event.FocusEvent

java.lang.Object
    |
    +----java.util.EventObject
            |
            +----java.awt.AWTEvent
                    |
                    +----java.awt.event.ComponentEvent
                            |
                            +----java.awt.event.FocusEvent

public class FocusEvent
extends ComponentEvent
A low-level event which indicates that a component has gained or lost the keyboard focus. This low-level event is generated by a component (such as a text field). The event is passed to every FocusListener or FocusAdapter object which registered to receive such events using the component's addFocusListener method. (FocusAdapter objects implement the FocusListener interface.) Each such listener object gets this FocusEvent when the event occurs.

There are two levels of focus change events: permanent and temporary. Permanent focus change events occur when focus is directly moved from one component to another, such as through calls to requestFocus() or as the user uses the Tab key to traverse components. Temporary focus change events occur when focus is temporarily gained or 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 levels may be distinguished in the event using the isTemporary() method.

See Also:
FocusAdapter, FocusListener, Tutorial: Writing a Focus Listener, Reference: The Java Class Libraries (update file)

Variable Index

 o FOCUS_FIRST
The first number in the range of ids used for focus events.
 o FOCUS_GAINED
This event indicates that the component gained the keyboard focus.
 o FOCUS_LAST
The last number in the range of ids used for focus events.
 o FOCUS_LOST
This event indicates that the component lost the keyboard focus.

Constructor Index

 o FocusEvent(Component, int)
Constructs a FocusEvent object and identifies it as a permanent change in focus.
 o FocusEvent(Component, int, boolean)
Constructs a FocusEvent object and identifies whether or not the change is temporary.

Method Index

 o isTemporary()
Identifies the focus change event as temporary or permanent.
 o paramString()
Returns a parameter string identifying this event.

Variables

 o FOCUS_FIRST
public static final int FOCUS_FIRST
The first number in the range of ids used for focus events.

 o FOCUS_LAST
public static final int FOCUS_LAST
The last number in the range of ids used for focus events.

 o FOCUS_GAINED
public static final int FOCUS_GAINED
This event indicates that the component gained the keyboard focus.

 o FOCUS_LOST
public static final int FOCUS_LOST
This event indicates that the component lost the keyboard focus.

Constructors

 o FocusEvent
public FocusEvent(Component source,
                  int id,
                  boolean temporary)
Constructs a FocusEvent object and identifies whether or not the change is temporary.

Parameters:
source - the Component that originated the event
id - an integer indicating the type of event
temporary - a boolean, true if the focus change is temporary
 o FocusEvent
public FocusEvent(Component source,
                  int id)
Constructs a FocusEvent object and identifies it as a permanent change in focus.

Parameters:
source - the Component that originated the event
id - an integer indicating the type of event

Methods

 o isTemporary
public boolean isTemporary()
Identifies the focus change event as temporary or permanent.

Returns:
a boolean value, true if the focus change is temporary
 o paramString
public String paramString()
Returns a parameter string identifying this event. This method is useful for event-logging and for debugging.

Returns:
a string identifying the event and its attributes
Overrides:
paramString in class ComponentEvent

All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Submit a bug or feature