public class WindowEvent extends ComponentEvent
事件传递到每一个WindowListener或WindowAdapter对象注册使用窗口的addWindowListener方法接收这样的事件。(WindowAdapter对象实现了WindowListener接口。)每个侦听器对象被这WindowEvent事件发生时。
未指定的行为将如果任何特定的WindowEvent实例的id参数不在WINDOW_FIRST到WINDOW_LAST范围造成的。
WindowAdapter,
WindowListener,
Tutorial: Writing a Window Listener,
Serialized Form
| Modifier and Type | Field and Description |
|---|---|
static int |
WINDOW_ACTIVATED
窗口激活事件类型。
|
static int |
WINDOW_CLOSED
窗口关闭事件。
|
static int |
WINDOW_CLOSING
“窗口关闭”事件。
|
static int |
WINDOW_DEACTIVATED
窗口停用事件类型。
|
static int |
WINDOW_DEICONIFIED
窗口deiconified事件类型。
|
static int |
WINDOW_FIRST
用于窗口事件的入侵检测系统的第一个数字。
|
static int |
WINDOW_GAINED_FOCUS
窗口获得焦点事件类型。
|
static int |
WINDOW_ICONIFIED
窗口图标化的事件。
|
static int |
WINDOW_LAST
用于窗口事件的入侵检测系统范围内的最后一个数字。
|
static int |
WINDOW_LOST_FOCUS
窗口丢失焦点事件类型。
|
static int |
WINDOW_OPENED
窗口打开事件。
|
static int |
WINDOW_STATE_CHANGED
窗口状态更改事件类型。
|
COMPONENT_FIRST, COMPONENT_HIDDEN, COMPONENT_LAST, COMPONENT_MOVED, COMPONENT_RESIZED, COMPONENT_SHOWNACTION_EVENT_MASK, ADJUSTMENT_EVENT_MASK, COMPONENT_EVENT_MASK, consumed, CONTAINER_EVENT_MASK, FOCUS_EVENT_MASK, HIERARCHY_BOUNDS_EVENT_MASK, HIERARCHY_EVENT_MASK, id, INPUT_METHOD_EVENT_MASK, INVOCATION_EVENT_MASK, ITEM_EVENT_MASK, KEY_EVENT_MASK, MOUSE_EVENT_MASK, MOUSE_MOTION_EVENT_MASK, MOUSE_WHEEL_EVENT_MASK, PAINT_EVENT_MASK, RESERVED_ID_MAX, TEXT_EVENT_MASK, WINDOW_EVENT_MASK, WINDOW_FOCUS_EVENT_MASK, WINDOW_STATE_EVENT_MASKsource| Constructor and Description |
|---|
WindowEvent(Window source, int id)
构建了一个
WindowEvent对象。
|
WindowEvent(Window source, int id, int oldState, int newState)
构建一个与指定窗口的状态
WindowEvent以前和新对象。
|
WindowEvent(Window source, int id, Window opposite)
构建一个与指定的相对
Window
WindowEvent对象。
|
WindowEvent(Window source, int id, Window opposite, int oldState, int newState)
构建了一个
WindowEvent对象。
|
| Modifier and Type | Method and Description |
|---|---|
int |
getNewState()
对于
WINDOW_STATE_CHANGED事件返回窗口的新状态。
|
int |
getOldState()
对于
WINDOW_STATE_CHANGED事件返回窗口以前的状态。
|
Window |
getOppositeWindow()
返回此焦点或激活更改所涉及的另一个窗口。
|
Window |
getWindow()
返回事件的发起人。
|
String |
paramString()
返回标识此事件的参数字符串。
|
getComponentgetSourcepublic static final int WINDOW_FIRST
@Native public static final int WINDOW_OPENED
@Native public static final int WINDOW_CLOSING
@Native public static final int WINDOW_CLOSED
@Native public static final int WINDOW_ICONIFIED
@Native public static final int WINDOW_DEICONIFIED
@Native public static final int WINDOW_ACTIVATED
@Native public static final int WINDOW_DEACTIVATED
@Native public static final int WINDOW_GAINED_FOCUS
@Native public static final int WINDOW_LOST_FOCUS
@Native public static final int WINDOW_STATE_CHANGED
public static final int WINDOW_LAST
public WindowEvent(Window source, int id, Window opposite, int oldState, int newState)
WindowEvent对象。
该方法抛出一个IllegalArgumentException如果source是null。
source -
Window对象产生的事件
id -整数表示事件的类型。在允许值的信息,看到
WindowEvent类的描述
opposite -其他窗口参与焦点或激活的变化,或
null
oldState -窗口状态变化事件的窗口之前的状态。看到
#getOldState()允许值
newState -窗口状态变化事件窗口的新状态。看到
#getNewState()允许值
IllegalArgumentException -如果
source是空的
getWindow(),
AWTEvent.getID(),
getOppositeWindow(),
getOldState(),
getNewState()
public WindowEvent(Window source, int id, Window opposite)
Window
WindowEvent对象。相反
Window是其他
Window参与这一焦点或活性的变化。一
WINDOW_ACTIVATED或
WINDOW_GAINED_FOCUS事件,这是失去焦点的
Window激活或。一
WINDOW_DEACTIVATED或
WINDOW_LOST_FOCUS事件,这是获得激活或焦点的
Window。如果焦点发生变化与本机应用程序,在不同的虚拟机的一个java应用程序,或没有其他
Window,那么相反
null
该方法抛出一个IllegalArgumentException如果source是null。
source -
Window对象产生的事件
id -整数表示事件的类型。在允许值的信息,看到
WindowEvent类的描述。预计该构造函数将不能用于其他然后
WINDOW_ACTIVATED,
WINDOW_DEACTIVATED,
WINDOW_GAINED_FOCUS,或
WINDOW_LOST_FOCUS。
WindowEvent类型,因为其他事件类型相反的
Window永远是
null。
opposite参与焦点或激活变化的另
Window,或
null
IllegalArgumentException -如果
source是空的
getWindow(),
AWTEvent.getID(),
getOppositeWindow()
public WindowEvent(Window source, int id, int oldState, int newState)
WindowEvent以前和新对象。
该方法抛出一个IllegalArgumentException如果source是null。
source -
Window对象产生的事件
id -整数表示事件的类型。在允许值的信息,看到
WindowEvent类的描述。据预计,该构造函数将不能用于其他然后
WINDOW_STATE_CHANGED
WindowEvent类型,因为以前的和新的窗口状态是毫无意义的其他事件类型。
oldState代表前面的窗口状态的整数。看到
#getOldState()允许值
newState代表新窗口状态的整数。看到
#getNewState()允许值
IllegalArgumentException -如果
source是空的
getWindow(),
AWTEvent.getID(),
getOldState(),
getNewState()
public WindowEvent(Window source, int id)
WindowEvent对象。
该方法抛出一个IllegalArgumentException如果source是null。
source -
Window对象产生的事件
id -整数表示事件的类型。在允许值的信息,看到
WindowEvent类的描述。
IllegalArgumentException -如果
source是空的
getWindow(),
AWTEvent.getID()
public Window getWindow()
public Window getOppositeWindow()
public int getOldState()
WINDOW_STATE_CHANGED事件返回窗口以前的状态。国家作为一位掩码。
NORMAL ICONIFIEDMAXIMIZED_HORIZMAXIMIZED_VERTMAXIMIZED_BOTH MAXIMIZED_HORIZ和MAXIMIZED_VERT。Frame.getExtendedState()
public int getNewState()
WINDOW_STATE_CHANGED事件返回窗口的新状态。国家作为一位掩码。
NORMAL ICONIFIEDMAXIMIZED_HORIZMAXIMIZED_VERTMAXIMIZED_BOTH MAXIMIZED_HORIZ和MAXIMIZED_VERT。Frame.getExtendedState()
public String paramString()
paramString 方法重写,继承类
ComponentEvent
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.