java::awt::event::FocusEvent Class Reference

Inheritance diagram for java::awt::event::FocusEvent:

Inheritance graph
java::awt::event::ComponentEventjava::awt::AWTEventjava::util::EventObjectjava::lang::Object
[legend]
Collaboration diagram for java::awt::event::FocusEvent:

Collaboration graph
java::awt::event::ComponentEventjava::awt::AWTEventjava::util::EventObjectjava::lang::Objectjava::lang::ObjectRefjava::lang::Interfacejava::lang::Comparable
[legend]

List of all members.


Detailed Description

A 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 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 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.

See also:
FocusAdapter

FocusListener

Tutorial: Writing a Focus Listener

Reference: The Java Class Libraries (update file)

Author:
Carl Quinn

Amy Fowler

Version:
1.28 01/23/03
Since:
1.1

Public Types

enum  FOCUS_EVENT_ID { FOCUS_FIRST = 1004, FOCUS_GAINED = FOCUS_FIRST, FOCUS_LOST, FOCUS_LAST = FOCUS_LOST }

Public Member Functions

 FocusEvent (const Ref< Component > &source=0, jint id=FOCUS_FIRST, jboolean tempoary=false, const Ref< Component > &opposite=0)
 Constructs a FocusEvent object with the specified temporary state and opposite Component.
virtual jboolean isTemporary () const
 Identifies the focus change event as temporary or permanent.
virtual Ref< ComponentgetOppositeComponent () const
 Returns the other Component involved in this focus change.
virtual String paramString () const
 Returns a parameter string identifying this event.

Protected Attributes

jboolean temporary
 A focus event can have two different levels, permanent and temporary.
Ref< Componentopposite
 The other Component involved in this focus change.

Member Enumeration Documentation

enum java::awt::event::FocusEvent::FOCUS_EVENT_ID

Enumerator:
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_LOST  This event indicates that the Component is no longer the focus owner.
FOCUS_LAST  The last number in the range of ids used for focus events.


Constructor & Destructor Documentation

java::awt::event::FocusEvent::FocusEvent ( const Ref< Component > &  source = 0,
jint  id = FOCUS_FIRST,
jboolean  tempoary = false,
const Ref< Component > &  opposite = 0 
)

Constructs a FocusEvent object with the specified temporary state and opposite Component.

The opposite Component is the other Component involved in this focus change. For a FOCUS_GAINED event, this is the Component that lost focus. For a FOCUS_LOST event, this is the Component that gained focus. If this focus change occurs with a native application, with a Java application in a different VM, or with no other Component, then the opposite Component is null.

Note that passing in an invalid id results in unspecified behavior.

Parameters:
source the Component that originated the event
id FOCUS_GAINED or FOCUS_LOST
temporary true if the focus change is temporary; false otherwise
opposite the other Component involved in the focus change, or null


Member Function Documentation

virtual jboolean java::awt::event::FocusEvent::isTemporary (  )  const [virtual]

Identifies the focus change event as temporary or permanent.

Returns:
true if the focus change is temporary; false otherwise

virtual Ref<Component> java::awt::event::FocusEvent::getOppositeComponent (  )  const [virtual]

Returns the other Component involved in this focus change.

For a FOCUS_GAINED event, this is the Component that lost focus. For a FOCUS_LOST event, this is the Component that gained focus. If this focus change occurs with a native application, with a Java application in a different VM or context, or with no other Component, then null is returned.

Returns:
the other Component involved in the focus change, or null
Since:
1.4

virtual String java::awt::event::FocusEvent::paramString (  )  const [virtual]

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

Reimplemented from java::awt::event::ComponentEvent.


Member Data Documentation

jboolean java::awt::event::FocusEvent::temporary [protected]

A focus event can have two different levels, permanent and temporary.

It will be set to true if some operation takes away the focus temporarily and intends on getting it back once the event is completed. Otherwise it will be set to false.

See also:
isTemporary

Ref<Component> java::awt::event::FocusEvent::opposite [protected]

The other Component involved in this focus change.

For a FOCUS_GAINED event, this is the Component that lost focus. For a FOCUS_LOST event, this is the Component that gained focus. If this focus change occurs with a native application, a Java application in a different VM, or with no other Component, then the opposite Component is null.

See also:
getOppositeComponent
Since:
1.4


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:15 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3