Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
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

This class represents an event generated when a focus change occurs for a component. There are both temporary changes, such as when focus is stolen during a sroll then returned, and permanent changes, such as when the user TABs through focusable components.

Since:Author:See Also:

Field Summary

static intFOCUS_FIRST

This is the first id in the range of ids used by this class.
static intFOCUS_GAINED

This is the event id for a focus gained event.
static intFOCUS_LAST

This is the last id in the range of ids used by this class.
static intFOCUS_LOST

This is the event id for a focus lost event.

Constructor Summary

FocusEvent(java.awt.Component source, int id, boolean temporary, java.awt.Component opposite)

Initializes a new instance of FocusEvent with the specified source, id, temporary status, and opposite counterpart.
FocusEvent(java.awt.Component source, int id, boolean temporary)

Initializes a new instance of FocusEvent with the specified source, id, and temporary status.
FocusEvent(java.awt.Component source, int id)

Initializes a new instance of FocusEvent with the specified source and id.

Method Summary

java.awt.ComponentgetOppositeComponent()

Returns the component which received the opposite focus event.
booleanisTemporary()

This method tests whether or not the focus change is temporary or permanent.
java.lang.StringparamString()

Returns a string identifying this event.

Field Details

FOCUS_FIRST

public static final int FOCUS_FIRST

This is the first id in the range of ids used by this class.


FOCUS_GAINED

public static final int FOCUS_GAINED

This is the event id for a focus gained event.


FOCUS_LAST

public static final int FOCUS_LAST

This is the last id in the range of ids used by this class.


FOCUS_LOST

public static final int FOCUS_LOST

This is the event id for a focus lost event.


Constructor Details

FocusEvent

public FocusEvent(java.awt.Component source, int id)

Initializes a new instance of FocusEvent with the specified source and id. Note that an invalid id leads to unspecified results.

Parameters:

Throws:


FocusEvent

public FocusEvent(java.awt.Component source, int id, boolean temporary)

Initializes a new instance of FocusEvent with the specified source, id, and temporary status. Note that an invalid id leads to unspecified results.

Parameters:

Throws:


FocusEvent

public FocusEvent(java.awt.Component source, int id, boolean temporary, java.awt.Component opposite)

Initializes a new instance of FocusEvent with the specified source, id, temporary status, and opposite counterpart. Note that an invalid id leads to unspecified results.

Parameters:

Throws:


Method Details

getOppositeComponent

public Component getOppositeComponent()

Returns the component which received the opposite focus event. If this component gained focus, the opposite lost focus; likewise if this component is giving up focus, the opposite is gaining it. If this information is unknown, perhaps because the opposite is a native application, this returns null.

Since:Returns:


isTemporary

public boolean isTemporary()

This method tests whether or not the focus change is temporary or permanent.

Returns:


paramString

public String paramString()

Returns a string identifying this event. This is formatted as: (getID() == FOCUS_GAINED ? "FOCUS_GAINED" : "FOCUS_LOST") + (isTemporary() ? ",temporary," : ",permanent,") + "opposite=" + getOppositeComponent().

Returns: