java.awt.event

Class ItemEvent

public class ItemEvent extends AWTEvent

This event is generated when a selection item changes state. This is an abstraction that distills a large number of individual mouse or keyboard events into a simpler "item selected" and "item deselected" events.

Since: 1.1

See Also: ItemSelectable ItemListener

UNKNOWN: updated to 1.4

Field Summary
static intDESELECTED
This type indicates that the item was deselected.
static intITEM_FIRST
This is the first id in the event id range used by this class.
static intITEM_LAST
This is the last id in the event id range used by this class.
static intITEM_STATE_CHANGED
This event id indicates a state change occurred.
static intSELECTED
This type indicates that the item was selected.
Constructor Summary
ItemEvent(ItemSelectable source, int id, Object item, int stateChange)
Initializes a new instance of ItemEvent with the specified source, id, and state change constant.
Method Summary
ObjectgetItem()
Returns the item affected by this state change.
ItemSelectablegetItemSelectable()
This method returns the event source as an ItemSelectable.
intgetStateChange()
Returns the type of state change, either {@link #SELECTED} or {@link #DESELECTED}.
StringparamString()
Returns a string identifying this event.

Field Detail

DESELECTED

public static final int DESELECTED
This type indicates that the item was deselected.

ITEM_FIRST

public static final int ITEM_FIRST
This is the first id in the event id range used by this class.

ITEM_LAST

public static final int ITEM_LAST
This is the last id in the event id range used by this class.

ITEM_STATE_CHANGED

public static final int ITEM_STATE_CHANGED
This event id indicates a state change occurred.

SELECTED

public static final int SELECTED
This type indicates that the item was selected.

Constructor Detail

ItemEvent

public ItemEvent(ItemSelectable source, int id, Object item, int stateChange)
Initializes a new instance of ItemEvent with the specified source, id, and state change constant. Note that an invalid id leads to unspecified results.

Parameters: source the source of the event id the event id item the item affected by the state change stateChange one of {@link #SELECTED} or {@link #DESELECTED}

Method Detail

getItem

public Object getItem()
Returns the item affected by this state change.

Returns: the item affected by this state change

getItemSelectable

public ItemSelectable getItemSelectable()
This method returns the event source as an ItemSelectable.

Returns: the event source as an ItemSelected

Throws: ClassCastException if source is changed to a non-ItemSelectable

getStateChange

public int getStateChange()
Returns the type of state change, either {@link #SELECTED} or {@link #DESELECTED}.

Returns: the type of state change

paramString

public String paramString()
Returns a string identifying this event. This is in the format: "ITEM_STATE_CHANGED,item=" + item + ",stateChange=" + (getStateChange() == DESELECTED ? "DESELECTED" : "SELECTED").

Returns: a string identifying this event