ItemEventpublic class ItemEvent extends AWTEvent 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". |
Fields Summary |
---|
public static final int | ITEM_FIRSTThe first number in the range of ids used for item events. | public static final int | ITEM_LASTThe last number in the range of ids used for item events. | public static final int | ITEM_STATE_CHANGEDThis event id indicates that an item's state changed. | public static final int | SELECTEDThis state-change value indicates that an item was selected. | public static final int | DESELECTEDThis state-change-value indicates that a selected item was deselected. | Object | itemThe item whose selection state has changed. | int | stateChangestateChange indicates whether the item
was selected or deselected. | private static final long | serialVersionUID |
Constructors Summary |
---|
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange)Constructs an ItemEvent object.
Note that passing in an invalid id results in
unspecified behavior. This method throws an
IllegalArgumentException if source
is null .
super(source, id);
this.item = item;
this.stateChange = stateChange;
|
Methods Summary |
---|
public java.lang.Object | getItem()Returns the item affected by the event.
return item;
| public java.awt.ItemSelectable | getItemSelectable()Returns the originator of the event.
return (ItemSelectable)source;
| public int | getStateChange()Returns the type of state change (selected or deselected).
return stateChange;
| public java.lang.String | paramString()Returns a parameter string identifying this item event.
This method is useful for event-logging and for debugging.
String typeStr;
switch(id) {
case ITEM_STATE_CHANGED:
typeStr = "ITEM_STATE_CHANGED";
break;
default:
typeStr = "unknown type";
}
String stateStr;
switch(stateChange) {
case SELECTED:
stateStr = "SELECTED";
break;
case DESELECTED:
stateStr = "DESELECTED";
break;
default:
stateStr = "unknown type";
}
return typeStr + ",item="+item + ",stateChange="+stateStr;
|
|