public class ContainerEvent extends ComponentEvent
集装箱事件仅供通报用途; AWT将自动处理内部对容器内容的更改,以使程序正常工作,而不管程序是否接收到这些事件。
当组件被添加到该组件或从其中删除时,此低级事件由容器对象(例如Panel)生成。 该事件传递给使用组件的addContainerListener方法注册接收此类事件的每个ContainerListener或ContainerAdapter对象。 ( ContainerAdapter对象实现ContainerListener接口)每个这样的侦听器对象在发生事件时得到这个ContainerEvent 。
如果未指定的行为将引起id任何特定的参数ContainerEvent实例不在范围从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
用于容器事件的ids范围中的第一个数字。
|
static int |
CONTAINER_LAST
用于容器事件的ids范围中的最后一个数字。
|
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 |
|---|
ContainerEvent(Component source, int id, Component child)
构造一个
ContainerEvent对象。
|
| Modifier and Type | Method and Description |
|---|---|
Component |
getChild()
返回受事件影响的组件。
|
Container |
getContainer()
返回事件的发起者。
|
String |
paramString()
返回标识此事件的参数字符串。
|
getComponentgetSourcepublic 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.