APIdia Launch Partner
Top Description Fields Constructors Methods
java.awt.event

public Class ItemEvent

extends AWTEvent
Class Inheritance
Imports
java.awt.AWTEvent, .ItemSelectable, java.io.Serial

A semantic event which indicates that an item was selected or deselected. This high-level event is generated by an ItemSelectable object (such as a List) when an item is selected or deselected by the user. The event is passed to every ItemListener object which registered to receive such events using the component's addItemListener method.

The object that implements the ItemListener interface gets this ItemEvent when the event occurs. The listener is spared the details of processing individual mouse movements and mouse clicks, and can instead process a "meaningful" (semantic) event like "item selected" or "item deselected".

An unspecified behavior will be caused if the id parameter of any particular ItemEvent instance is not in the range from ITEM_FIRST to ITEM_LAST.

The stateChange of any ItemEvent instance takes one of the following values:

Assigning the value different from listed above will cause an unspecified behavior.
Author
Carl Quinn
Since
1.1
See Also
java.awt.ItemSelectable, ItemListener, Tutorial: Writing an Item Listener

Field Summary

Modifier and TypeField and Description
public static final int
DESELECTED

This state-change-value indicates that a selected item was deselected.

pack-priv Object
item

The item whose selection state has changed.

public static final int
ITEM_FIRST

The first number in the range of ids used for item events.

public static final int
ITEM_LAST

The last number in the range of ids used for item events.

public static final int
ITEM_STATE_CHANGED

This event id indicates that an item's state changed.

public static final int
SELECTED

This state-change value indicates that an item was selected.

private static final long
serialVersionUID

Hides java.awt.AWTEvent.serialVersionUID.

Use serialVersionUID from JDK 1.1 for interoperability.
pack-priv int
stateChange

stateChange indicates whether the item was selected or deselected.

Inherited from java.awt.AWTEvent:
ACTION_EVENT_MASKADJUSTMENT_EVENT_MASKCOMPONENT_EVENT_MASKconsumedCONTAINER_EVENT_MASKFOCUS_EVENT_MASKHIERARCHY_BOUNDS_EVENT_MASKHIERARCHY_EVENT_MASKidINPUT_METHOD_EVENT_MASKINVOCATION_EVENT_MASKITEM_EVENT_MASKKEY_EVENT_MASKMOUSE_EVENT_MASKMOUSE_MOTION_EVENT_MASKMOUSE_WHEEL_EVENT_MASKPAINT_EVENT_MASKRESERVED_ID_MAXTEXT_EVENT_MASKWINDOW_EVENT_MASKWINDOW_FOCUS_EVENT_MASKWINDOW_STATE_EVENT_MASK

Constructor Summary

AccessConstructor and Description
public
ItemEvent(ItemSelectable
The ItemSelectable object that originated the event
source
,
int
The integer that identifies the event type. For information on allowable values, see the class description for ItemEvent
id
,
Object
An object -- the item affected by the event
item
,
int
An integer that indicates whether the item was selected or deselected. For information on allowable values, see the class description for ItemEvent
stateChange
)

Constructs an ItemEvent object.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

the item (object) that was affected by the event
getItem
()

Returns the item affected by the event.

public ItemSelectable

Returns:

the ItemSelectable object that originated the event.
getItemSelectable
()

Returns the originator of the event.

public int

Returns:

an integer that indicates whether the item was selected or deselected
getStateChange
()

Returns the type of state change (selected or deselected).

public String

Returns:

a string identifying the event and its attributes
paramString
()

Overrides java.awt.AWTEvent.paramString.

Returns a parameter string identifying this item event.

Inherited from java.awt.AWTEvent:
consumegetIDisConsumedsetSourcetoString

Field Detail

DESELECTEDback to summary
public static final int DESELECTED

This state-change-value indicates that a selected item was deselected.

itemback to summary
pack-priv Object item

The item whose selection state has changed.

Annotations
@SuppressWarnings:serial
See Also
getItem()
ITEM_FIRSTback to summary
public static final int ITEM_FIRST

The first number in the range of ids used for item events.

ITEM_LASTback to summary
public static final int ITEM_LAST

The last number in the range of ids used for item events.

ITEM_STATE_CHANGEDback to summary
public static final int ITEM_STATE_CHANGED

This event id indicates that an item's state changed.

SELECTEDback to summary
public static final int SELECTED

This state-change value indicates that an item was selected.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.awt.AWTEvent.serialVersionUID.

Use serialVersionUID from JDK 1.1 for interoperability.

Annotations
@Serial
stateChangeback to summary
pack-priv int stateChange

stateChange indicates whether the item was selected or deselected.

See Also
getStateChange()

Constructor Detail

ItemEventback to summary
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange)

Constructs an ItemEvent object.

This method throws an IllegalArgumentException if source is null.

Parameters
source:ItemSelectable

The ItemSelectable object that originated the event

id:int

The integer that identifies the event type. For information on allowable values, see the class description for ItemEvent

item:Object

An object -- the item affected by the event

stateChange:int

An integer that indicates whether the item was selected or deselected. For information on allowable values, see the class description for ItemEvent

Exceptions
IllegalArgumentException:
if source is null
See Also
getItemSelectable(), getID(), getStateChange()

Method Detail

getItemback to summary
public Object getItem()

Returns the item affected by the event.

Returns:Object

the item (object) that was affected by the event

getItemSelectableback to summary
public ItemSelectable getItemSelectable()

Returns the originator of the event.

Returns:ItemSelectable

the ItemSelectable object that originated the event.

getStateChangeback to summary
public int getStateChange()

Returns the type of state change (selected or deselected).

Returns:int

an integer that indicates whether the item was selected or deselected

See Also
SELECTED, DESELECTED
paramStringback to summary
public String paramString()

Overrides java.awt.AWTEvent.paramString.

Returns a parameter string identifying this item event. This method is useful for event-logging and for debugging.

Returns:String

a string identifying the event and its attributes