public class ComponentEvent extends AWTEvent
组件事件仅供通知用途; AWT将自动处理组件移动并在内部调整大小,以使GUI布局正常工作,而不管程序是否接收这些事件。
除了作为其他组件相关事件(InputEvent,FocusEvent,WindowEvent,ContainerEvent)的基类之外,此类还定义了指示组件大小,位置或可见性更改的事件。
 当组件移动,调整大小,呈现不可见或再次可见时,此低级事件由组件对象(例如List)生成。 该事件传递给使用组件的addComponentListener方法注册接收此类事件的每个ComponentListener或ComponentAdapter对象。 ( ComponentAdapter对象实现ComponentListener接口。)每个这样的侦听器对象在事件发生时得到这个ComponentEvent 。 
 如果未指定的行为将引起id任何特定的参数ComponentEvent实例不在范围从COMPONENT_FIRST到COMPONENT_LAST 。 
ComponentAdapter , ComponentListener , Tutorial: Writing a Component Listener , Serialized Form 
       | Modifier and Type | Field and Description | 
|---|---|
| static int | COMPONENT_FIRST
              用于组件事件的ids范围中的第一个数字。 
             | 
| static int | COMPONENT_HIDDEN
              此事件表示该组件被呈现为不可见。 
             | 
| static int | COMPONENT_LAST
              用于组件事件的ID的范围中的最后一个数字。 
             | 
| 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_MASKsource| Constructor and Description | 
|---|
| ComponentEvent(Component source, int id)
              构造一个 
              ComponentEvent对象。 | 
| Modifier and Type | Method and Description | 
|---|---|
| Component | getComponent()
              返回事件的发起者。 
             | 
| String | paramString()
              返回标识此事件的参数字符串。 
             | 
getSourcepublic 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.