java.awt.event

Interface ItemListener

All Superinterfaces:
EventListener
Known Implementing Classes:
AWTEventMulticaster, BasicComboBoxUI.ItemHandler, BasicComboPopup.ItemHandler, Checkbox.AccessibleAWTCheckbox, DefaultCellEditor.EditorDelegate, JCheckBox.AccessibleJCheckBox, JRadioButton.AccessibleJRadioButton, JToggleButton.AccessibleJToggleButton, List.AccessibleAWTList, ThreadGroupGui

public interface ItemListener
extends EventListener

The listener interface for receiving item events. The class that is interested in processing an item event implements this interface. The object created with that class is then registered with a component using the component's addItemListener method. When an item-selection event occurs, the listener object's itemStateChanged method is invoked.
Since:
1.1
See Also:
ItemSelectable, ItemEvent, Tutorial: Writing an Item Listener, Reference: The Java Class Libraries (update file)

Method Summary

void
itemStateChanged(ItemEvent e)
Invoked when an item has been selected or deselected by the user.

Method Details

itemStateChanged

public void itemStateChanged(ItemEvent e)
Invoked when an item has been selected or deselected by the user. The code written for this method performs the operations that need to occur when an item is selected (or deselected).
Usages and Demos :

View More Examples of itemStateChanged(ItemEvent e)
   1: @SuppressWarnings("serial")
   2: public class JCoolTabbed extends JPanel implements ItemListener
   3: {
   4:         ...
   5:     {
   6:         ItemListener[] arr = listenerList.getListeners(ItemListener.class) ;
   7:         ...
   8:         for(ItemListener l : arr)
   9:         ...
  10:             l.itemStateChanged(e) ;

View Full Code Here
   1:   private Component previous;
   2:   private ItemListener itemListener;
   3:   private ItemEvent itemEvent;
   4:         ...
   5: 
   6:     if((current!=null)&&(itemListener!=null)) {
   7:       itemEvent=new ItemEvent(this, 0, current, ItemEvent.DESELECTED);
   8:         ...
   9:       itemListener.itemStateChanged(itemEvent);
  10:     }
  11:         ...
  12:       itemEvent=new ItemEvent(this, 0, current, ItemEvent.SELECTED);
  13:       itemListener.itemStateChanged(itemEvent);

View Full Code Here
   1: 
   2:     transient ItemListener itemListener;
   3:         ...
   4:     public synchronized void addItemListener(ItemListener l) {
   5:         itemListener = AWTEventMulticaster.add(itemListener, l);
   6:         ...
   7:         if (itemListener != null) {
   8:             itemListener.itemStateChanged(evt);
   9:         }

View Full Code Here
   1: import jp.ujihara.java.awt.event.ItemEvent;
   2: import jp.ujihara.java.awt.event.ItemListener;
   3: import jp.ujihara.java.awt.peer.CheckboxMenuItemPeer;
   4:         ...
   5: 
   6: private transient ItemListener item_listeners;
   7: 
   8:         ...
   9: 
  10: public synchronized void addItemListener(ItemListener listener)
  11: {
  12:         ...
  13:   if (item_listeners != null)
  14:     item_listeners.itemStateChanged(event);

View Full Code Here
   1: import jp.ujihara.java.awt.event.ItemEvent;
   2: import jp.ujihara.java.awt.event.ItemListener;
   3: import jp.ujihara.java.awt.peer.CheckboxPeer;
   4:         ...
   5: 
   6: private transient ItemListener item_listeners;
   7: 
   8:         ...
   9: 
  10:   public ItemListener[] getItemListeners ()
  11:   {
  12:         ...
  13:   if (item_listeners != null)
  14:     item_listeners.itemStateChanged(event);

View Full Code Here