|
JavaTM 2 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 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。