public class ComponentEvent extends AWTEvent
组件事件提供通知的目的;AWT组件将自动处理移动和调整内部,界面布局工作正常,不管程序是否接收这些事件或不。
除了作为其他组件的相关事件的基类(inputevent、键盘、窗口事件类,containerevent),这类定义的事件表明在一个组件的大小、位置变化,或能见度。
这种低层次的事件是由一个组件对象生成的(如表)当元件移动,调整大小,使看不见的,还是可见的。事件传递到每一个ComponentListener
或ComponentAdapter
对象注册到使用组件的addComponentListener
方法接收这样的事件。(ComponentAdapter
对象实现了ComponentListener
接口。)每个侦听器对象被这ComponentEvent
事件发生时。
未指定的行为将如果任何特定的ComponentEvent
实例的id
参数不在COMPONENT_FIRST
到COMPONENT_LAST
范围造成的。
ComponentAdapter
,
ComponentListener
,
Tutorial: Writing a Component Listener,
Serialized Form
Modifier and Type | Field and Description |
---|---|
static int |
COMPONENT_FIRST
用于组件事件的入侵检测系统范围内的第一个数字。
|
static int |
COMPONENT_HIDDEN
此事件指示该组件呈现不可见的。
|
static int |
COMPONENT_LAST
用于组件事件的入侵检测系统范围内的最后一个数字。
|
static int |
COMPONENT_MOVED
此事件指示组件的位置发生了更改。
|
static int |
COMPONENT_RESIZED
此事件表示组件的大小更改了。
|
static int |
COMPONENT_SHOWN
此事件指示该组件是可见的。
|
ACTION_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_MASK
source
Constructor and Description |
---|
ComponentEvent(Component source, int id)
构建了一个
ComponentEvent 对象。
|
Modifier and Type | Method and Description |
---|---|
Component |
getComponent()
返回事件的发起人。
|
String |
paramString()
返回标识此事件的参数字符串。
|
getSource
public static final int COMPONENT_FIRST
public static final int COMPONENT_LAST
@Native public static final int COMPONENT_MOVED
@Native public static final int COMPONENT_RESIZED
@Native public static final int COMPONENT_SHOWN
@Native public static final int COMPONENT_HIDDEN
public ComponentEvent(Component source, int id)
ComponentEvent
对象。
该方法抛出一个IllegalArgumentException
如果source
是null
。
source
-
Component
起源事件
id
-整数表示事件的类型。在允许值的信息,看到
ComponentEvent
类的描述
IllegalArgumentException
-如果
source
是空的
getComponent()
,
AWTEvent.getID()
public Component getComponent()
Component
对象产生的事件,或
null
如果对象不是一个
Component
。
public String paramString()
paramString
方法重写,继承类
AWTEvent
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.