public class ItemEvent extends AWTEvent
ItemListener
对象注册到使用组件的
addItemListener
方法接收这样的事件。
实现ItemListener
接口获取这ItemEvent
事件发生时的对象。听者不处理单个鼠标移动和鼠标点击的细节,可以替代过程中的一个“有意义的”(语义)的事件如“选项”或“项目取消”。
未指定的行为将如果任何特定的ItemEvent
实例的id
参数不在ITEM_FIRST
到ITEM_LAST
范围造成的。
任何ItemEvent
实例的stateChange
取下列值之一:
ItemEvent.SELECTED
ItemEvent.DESELECTED
ItemSelectable
,
ItemListener
,
Tutorial: Writing an Item Listener,
Serialized Form
Modifier and Type | Field and Description |
---|---|
static int |
DESELECTED
这种状态的变化值表示所选项目被取消。
|
static int |
ITEM_FIRST
用于项目事件的入侵检测系统的第一个数字。
|
static int |
ITEM_LAST
用于项目事件的入侵检测范围的最后一个数字。
|
static int |
ITEM_STATE_CHANGED
此事件表示一个项目的状态更改。
|
static int |
SELECTED
此状态更改值指示一个项目被选中。
|
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 |
---|
ItemEvent(ItemSelectable source, int id, Object item, int stateChange)
构建了一个
ItemEvent 对象。
|
Modifier and Type | Method and Description |
---|---|
Object |
getItem()
返回受事件影响的项目。
|
ItemSelectable |
getItemSelectable()
返回事件的发起人。
|
int |
getStateChange()
返回类型的状态变化(选择或取消选择)。
|
String |
paramString()
返回一个参数字符串,确定该项目事件。
|
getSource
public static final int ITEM_FIRST
public static final int ITEM_LAST
public static final int ITEM_STATE_CHANGED
public static final int SELECTED
public static final int DESELECTED
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange)
ItemEvent
对象。
该方法抛出一个IllegalArgumentException
如果source
是null
。
source
-
ItemSelectable
对象产生的事件
id
-标识事件类型的整数。在允许值的信息,看到
ItemEvent
类的描述
item
-对象-项目影响的事件
stateChange
-一个整数,表示项目是否被选中或取消选中。在允许值的信息,看到
ItemEvent
类的描述
IllegalArgumentException
-如果
source
是空的
getItemSelectable()
,
AWTEvent.getID()
,
getStateChange()
public ItemSelectable getItemSelectable()
public Object getItem()
public int getStateChange()
SELECTED
,
DESELECTED
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.