Java AWT

Previous Chapter 21
java.awt.event Reference
Next
 

ItemEvent (New)

Name

ItemEvent (New)

[Graphic: Figure from the text]

Description

ItemEvents are generated by objects that implement the ItemSelectable interface. Choice is one example of such an object.

Class Definition

public class java.awt.event.ItemEvent
   extends java.awt.AWTEvent {
  // Constants
  public final static int DESELECTED;
  public final static int ITEM_FIRST;
  public final static int ITEM_LAST;
  public final static int ITEM_STATE_CHANGED;
  public final static int SELECTED;
  // Constructors
  public ItemEvent (ItemSelectable source, int id, Object item, int stateChange);
  
// Instance Methods
  public Object getItem();
  public ItemSelectable getItemSelectable();
  public int getStateChange();
  public String paramString();
}

Constants

DESELECTED

public final static int DESELECTED

Indicates that an item was deselected.

ITEM_FIRST

public final static int ITEM_FIRST

Specifies the beginning range of item event ID values.

ITEM_LAST

public final static int ITEM_LAST

Specifies the ending range of item event ID values.

ITEM_STATE_CHANGED

public final static int ITEM_STATE_CHANGED

An event type indicating that an item was selected or deselected.

SELECTED

public final static int SELECTED

Indicates that an item was selected.

Constructors

ItemEvent

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

Parameters

source

The object that generated the event.

id

The type ID of the event.

item

The item whose state is changing.

stateChange

Either SELECTED or DESELECTED.

Description

Constructs an ItemEvent with the given characteristics.

Instance Methods

getItem

public Object getItem()

Returns

The item pertaining to this event.

Description

Returns the item whose changed state triggered this event.

getItemSelectable

public ItemSelectable getItemSelectable()

Returns

The source of this event.

Description

Returns an object that implements the ItemSelectable interface.

getStateChange

public int getStateChange()

Returns

The change in state that triggered this event. The new state is returned.

Description

This method will return SELECTED or DESELECTED.

paramString

public String paramString()

Returns

String with current settings of ItemEvent.

Overrides

AWTEvent.paramString()

Description

Helper method for toString() to generate string of current settings.

See Also

AWTEvent, ItemSelectable, ItemListener


Previous Home Next
InputEvent (New) Book Index ItemListener (New)

Java in a Nutshell Java Language Reference Java AWT Java Fundamental Classes Exploring Java