- java.lang.Object
-
- java.util.EventObject
-
- java.awt.AWTEvent
-
- java.awt.event.ComponentEvent
-
- All Implemented Interfaces:
-
Serializable
- 已知直接子类:
-
ContainerEvent,FocusEvent,InputEvent,PaintEvent,WindowEvent
public class ComponentEvent extends AWTEvent
指示组件移动,更改大小或更改可见性的低级事件(也称为其他组件级事件的根类)。组件事件仅供通知用途; AWT将自动处理组件移动并在内部调整大小,以使GUI布局正常工作,而不管程序是否正在接收这些事件。
除了作为其他组件相关事件(InputEvent,FocusEvent,WindowEvent,ContainerEvent)的基类之外,此类还定义了指示组件大小,位置或可见性变化的事件。
当组件移动,调整大小,呈现不可见或再次可见时,此低级事件由组件对象(例如List)生成。 事件被传递给每个
ComponentListener或ComponentAdapter对象,其注册使用组件的addComponentListener方法接收此类事件。 (ComponentAdapter对象实现ComponentListener接口。)当事件发生时,每个这样的侦听器对象获得这个ComponentEvent。如果任何特定的
ComponentEvent实例的id参数不在从COMPONENT_FIRST到COMPONENT_LAST的范围内,将会导致未指定的行为。- 从以下版本开始:
- 1.1
- 另请参见:
-
ComponentAdapter,ComponentListener, Tutorial: Writing a Component Listener , Serialized Form
-
-
Field Summary
Fields Modifier and Type Field 描述 static intCOMPONENT_FIRST用于组件事件的ids范围中的第一个数字。static intCOMPONENT_HIDDEN此事件表示该组件被呈现为不可见。static intCOMPONENT_LAST用于组件事件的ID的范围中的最后一个数字。static intCOMPONENT_MOVED此事件表示组件的位置已更改。static intCOMPONENT_RESIZED此事件表示组件的大小已更改。static intCOMPONENT_SHOWN此事件表示组件已显示。-
Fields inherited from class java.awt.AWTEvent
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
-
Fields inherited from class java.util.EventObject
source
-
-
构造方法摘要
构造方法 Constructor 描述 ComponentEvent(Component source, int id)构造一个ComponentEvent对象。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 ComponentgetComponent()返回事件的发起者。StringparamString()返回标识此事件的参数字符串。-
Methods inherited from class java.util.EventObject
getSource
-
-
-
-
字段详细信息
-
COMPONENT_FIRST
public static final int COMPONENT_FIRST
用于组件事件的ids范围中的第一个数字。- 另请参见:
- Constant Field Values
-
COMPONENT_LAST
public static final int COMPONENT_LAST
用于组件事件的ID的范围中的最后一个数字。- 另请参见:
- Constant Field Values
-
COMPONENT_MOVED
@Native public static final int COMPONENT_MOVED
此事件表示组件的位置已更改。- 另请参见:
- Constant Field Values
-
COMPONENT_RESIZED
@Native public static final int COMPONENT_RESIZED
此事件表示组件的大小已更改。- 另请参见:
- Constant Field Values
-
COMPONENT_SHOWN
@Native public static final int COMPONENT_SHOWN
此事件表示组件已显示。- 另请参见:
- Constant Field Values
-
COMPONENT_HIDDEN
@Native public static final int COMPONENT_HIDDEN
此事件表示该组件被呈现为不可见。- 另请参见:
- Constant Field Values
-
-
构造方法详细信息
-
ComponentEvent
public ComponentEvent(Component source, int id)
构造一个ComponentEvent对象。此方法抛出
IllegalArgumentException如果source为null。- 参数
-
source- 发起事件的Component -
id- 指示事件类型的整数。 有关允许值的信息,请参阅ComponentEvent的类描述 - 异常
-
IllegalArgumentException- 如果source为空 - 另请参见:
-
getComponent(),AWTEvent.getID()
-
-
方法详细信息
-
getComponent
public Component getComponent()
返回事件的发起者。- 结果
-
所述
Component对象发起事件,或null,如果对象不是Component。
-
paramString
public String paramString()
返回标识此事件的参数字符串。 此方法对于事件记录和调试很有用。- 重写:
-
paramString类AWTEvent - 结果
- 标识事件及其属性的字符串
-
-