Friday, 21 February 2014

EVENT CLASSES:The ItemEvent Class

an item was selected or deselected....


ItemEvent class:

A semantic event which indicates that an item was selected or deselected.Defines the itemStateChanged() method when an item has been 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 stateChange of any ItemEvent instance takes one of the following values:


  • DESELECTED:   The user deselected an item

           syntax:
             ItemEvent.DESELECTED


  • SELECTED: The user selected an item.

            syntax:
                 ItemEvent.SELECTED



ItemEvent  has this constructor:


              ItemEvent(ItemSelectable src,int type,Object entry,int state)

Here src is a refernce to the that generated this event..The type of event specified by the type.the specific item  that generated the item event is passed the entryThe current state of that item is in state.

Methods in ItemEvent:

  • getItem():

      The getItem() method can be used to obtain a reference to the item that generated an event.

syntax;
      object getItem()


  • getItemSelectable():

           The getItemSelectable() method can be used to obtain a reference to the ItemSelectable object that generated an event.

syntax:
          ItemSelectable getItemSelectable()


  • getStateChange():

        The getStateChange() method return the state  change(i.e.,SELECTED or DESELECTED)for the event.

syntax:
         int getStateChange()

No comments:

Post a Comment