Spec-Zone .ru
спецификации, руководства, описания, API
JavaTM 2 Platform
Standard Edition

java.awt.event
Class 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), Serialized Form

Field Summary
static int FOCUS_FIRST
          The first number in the range of ids used for focus events.
static int FOCUS_GAINED
          This event indicates that the component gained the keyboard focus.
static int FOCUS_LAST
          The last number in the range of ids used for focus events.
static int FOCUS_LOST
          This event indicates that the component lost the keyboard focus.
 
Fields inherited from class java.awt.event.ComponentEvent
COMPONENT_FIRST, COMPONENT_HIDDEN, COMPONENT_LAST, COMPONENT_MOVED, COMPONENT_RESIZED, COMPONENT_SHOWN
 
Fields inherited from class java.awt.AWTEvent
ACTION_EVENT_MASK, ADJUSTMENT_EVENT_MASK, COMPONENT_EVENT_MASK, consumed, CONTAINER_EVENT_MASK, FOCUS_EVENT_MASK, id, INPUT_METHOD_EVENT_MASK, ITEM_EVENT_MASK, KEY_EVENT_MASK, MOUSE_EVENT_MASK, MOUSE_MOTION_EVENT_MASK, RESERVED_ID_MAX, TEXT_EVENT_MASK, WINDOW_EVENT_MASK
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
FocusEvent(Component source, int id)
          Constructs a FocusEvent object and identifies it as a permanent change in focus.
FocusEvent(Component source, int id, boolean temporary)
          Constructs a FocusEvent object and identifies whether or not the change is temporary.
 
Method Summary
 boolean isTemporary()
          Identifies the focus change event as temporary or permanent.
 String paramString()
          Returns a parameter string identifying this event.
 
Methods inherited from class java.awt.event.ComponentEvent
getComponent
 
Methods inherited from class java.awt.AWTEvent
consume, finalize, getID, isConsumed, toString
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FOCUS_FIRST

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

FOCUS_LAST

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

FOCUS_GAINED

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

FOCUS_LOST

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

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

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
Method Detail

isTemporary

public boolean isTemporary()
Identifies the focus change event as temporary or permanent.
Returns:
a boolean value, true if the focus change is temporary

paramString

public String paramString()
Returns a parameter string identifying this event. This method is useful for event-logging and for debugging.
Overrides:
paramString in class ComponentEvent
Returns:
a string identifying the event and its attributes

JavaTM 2 Platform
Standard Edition

Submit a bug or feature
Java, Java 2D, and JDBC are a trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.