|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjava.util.EventObject
java.awt.AWTEvent
java.awt.event.ComponentEvent
java.awt.event.FocusEvent
public class FocusEvent
指示 Component 已获得或失去输入焦点的低级别事件。此低级别事件由 Component(比如 TextField)生成。事件被传递给每一个 FocusListener 或 FocusAdapter 对象,这些对象使用 Component 的 addFocusListener 方法注册,以接收这类事件。(FocusAdapter 对象实现 FocusListener 接口。)当发生该事件时,所有这类侦听器对象都将获得此 FocusEvent。
有两个焦点事件级别:持久性的和暂时性的。当焦点直接从一个 Component 移动到另一个 Component 时(比如通过调用 requestFocus(),或者用户使用 TAB 键遍历 Component 时),发生持久性焦点更改事件。当由于另一个操作(比如释放 Window 或拖动 Scrollbar)间接引起 Component 暂时失去焦点时,发生暂时性焦点更改事件。在这种情况下,一旦该操作结束,将自动恢复原始焦点状态,对于释放 Window 的情况来说,重新激活 Window 就能恢复原始焦点状态。持久性焦点事件和暂时性焦点事件使用 FOCUS_GAINED 和 FOCUS_LOST 事件 id 传递;可以使用 isTemporary() 方法区分事件的级别。
FocusAdapter,
FocusListener,
Tutorial: Writing a Focus Listener,
序列化表格| 字段摘要 | |
|---|---|
static int |
FOCUS_FIRST
用于焦点事件的 id 范围的起始编号。 |
static int |
FOCUS_GAINED
此事件指示 Component 现在是焦点所有者。 |
static int |
FOCUS_LAST
用于焦点事件的 id 范围的结束编号。 |
static int |
FOCUS_LOST
此事件指示 Component 不再是焦点所有者。 |
| 从类 java.awt.event.ComponentEvent 继承的字段 |
|---|
COMPONENT_FIRST, COMPONENT_HIDDEN, COMPONENT_LAST, COMPONENT_MOVED, COMPONENT_RESIZED, COMPONENT_SHOWN |
| 从类 java.util.EventObject 继承的字段 |
|---|
source |
| 构造方法摘要 | |
|---|---|
FocusEvent(Component source,
int id)
构造一个 FocusEvent 对象,并将它标识为一个持久性焦点更改。 |
|
FocusEvent(Component source,
int id,
boolean temporary)
构造一个 FocusEvent 对象,并将标识更改是否为暂时的。 |
|
FocusEvent(Component source,
int id,
boolean temporary,
Component opposite)
构造一个 FocusEvent 对象,它具有指定的暂时状态和对立 Component。 |
|
| 方法摘要 | |
|---|---|
Component |
getOppositeComponent()
返回此焦点更改中涉及的另一个 Component。 |
boolean |
isTemporary()
将焦点更改事件标识为暂时性的或持久性的。 |
String |
paramString()
返回标识此事件的参数字符串。 |
| 从类 java.awt.event.ComponentEvent 继承的方法 |
|---|
getComponent |
| 从类 java.awt.AWTEvent 继承的方法 |
|---|
consume, getID, isConsumed, setSource, toString |
| 从类 java.util.EventObject 继承的方法 |
|---|
getSource |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 字段详细信息 |
|---|
public static final int FOCUS_FIRST
public static final int FOCUS_LAST
public static final int FOCUS_GAINED
public static final int FOCUS_LOST
| 构造方法详细信息 |
|---|
public FocusEvent(Component source,
int id,
boolean temporary,
Component opposite)
FocusEvent 对象,它具有指定的暂时状态和对立 Component。对立 Component 是在此焦点更改中涉及的另一个 Component。对于 FOCUS_GAINED 事件,该组件是失去焦点的 Component。对于 FOCUS_LOST 事件,该组件是获得焦点的 Component。如果此焦点更改发生在本机应用程序、不同 VM 中的 Java 应用程序或没有其他 Component 的情况下,则对立 Component 为 null。
注意,传入无效 id 会导致未指定的行为。如果 source 为 null,则此方法抛出 IllegalArgumentException。
source - 发起事件的 Componentid - FOCUS_GAINED 或 FOCUS_LOSTtemporary - 如果焦点更改是暂时的,则为 true;否则为 falseopposite - 焦点更改中涉及的另一个 Component,或者为 null
IllegalArgumentException - 如果 source 为 null
public FocusEvent(Component source,
int id,
boolean temporary)
FocusEvent 对象,并将标识更改是否为暂时的。
注意,传入无效 id 会导致未指定的行为。如果 source 为 null,则此方法抛出 IllegalArgumentException。
source - 发起事件的 Componentid - 指示事件类型的整数temporary - 如果焦点更改是暂时的,则为 true;否则为 false
IllegalArgumentException - 如果 source 为 null
public FocusEvent(Component source,
int id)
FocusEvent 对象,并将它标识为一个持久性焦点更改。
注意,传入无效 id 会导致未指定的行为。如果 source 为 null,则此方法抛出 IllegalArgumentException。
source - 发起事件的 Componentid - 指示事件类型的整数
IllegalArgumentException - 如果 source 为 null| 方法详细信息 |
|---|
public boolean isTemporary()
true;否则返回 falsepublic Component getOppositeComponent()
public String paramString()
ComponentEvent 中的 paramString
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。