public class ContainerEvent extends ComponentEvent
集装箱事件仅提供通知的目的;AWT将自动处理的容器内容的内部,程序工作正常,不管程序是否接收这些事件或不变化。
这个低级的事件是由一个容器对象(如面板)产生的,当一个组件被添加到它或从它被删除。事件传递到每一个ContainerListener
或ContainerAdapter
对象注册到使用组件的addContainerListener
方法接收这样的事件。(ContainerAdapter
对象实现了ContainerListener
接口。)每个侦听器对象被这ContainerEvent
事件发生时。
未指定的行为将如果任何特定的ContainerEvent
实例的id
参数不在CONTAINER_FIRST
到CONTAINER_LAST
范围造成的。
ContainerAdapter
,
ContainerListener
,
Tutorial: Writing a Container Listener,
Serialized Form
Modifier and Type | Field and Description |
---|---|
static int |
COMPONENT_ADDED
此事件指示容器中添加了一个组件。
|
static int |
COMPONENT_REMOVED
此事件指示从容器中删除了一个组件。
|
static int |
CONTAINER_FIRST
用于容器事件的入侵检测系统中的第一个数字。
|
static int |
CONTAINER_LAST
用于容器事件的入侵检测系统中的最后一个数字。
|
COMPONENT_FIRST, COMPONENT_HIDDEN, COMPONENT_LAST, COMPONENT_MOVED, COMPONENT_RESIZED, 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 |
---|
ContainerEvent(Component source, int id, Component child)
构建了一个
ContainerEvent 对象。
|
Modifier and Type | Method and Description |
---|---|
Component |
getChild()
返回事件影响的组件。
|
Container |
getContainer()
返回事件的发起人。
|
String |
paramString()
返回标识此事件的参数字符串。
|
getComponent
getSource
public static final int CONTAINER_FIRST
public static final int CONTAINER_LAST
public static final int COMPONENT_ADDED
public static final int COMPONENT_REMOVED
public ContainerEvent(Component source, int id, Component child)
ContainerEvent
对象。
该方法抛出一个IllegalArgumentException
如果source
是null
。
source
-
Component
对象(容器)发起的事件
id
-整数表示事件的类型。在允许值的信息,看到
ContainerEvent
类的描述
child
的部分,添加或删除
IllegalArgumentException
-如果
source
是空的
getContainer()
,
AWTEvent.getID()
,
getChild()
public Container getContainer()
Container
对象产生的事件,或
null
如果对象不是一个
Container
。
public Component getChild()
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.