FileDocCategorySizeDatePackage
ItemFrame.javaAPI DocExample2087Mon Mar 24 02:02:32 GMT 1997None

ItemEventComponent

public class ItemEventComponent extends Component implements ItemSelectable

Fields Summary
boolean
selected
int
i
ItemListener
itemListener
Constructors Summary
ItemEventComponent()

      
        enableEvents (AWTEvent.MOUSE_EVENT_MASK);
    
Methods Summary
public voidaddItemListener(java.awt.event.ItemListener l)

        itemListener = AWTEventMulticaster.add (itemListener, l);
    
public java.lang.Object[]getSelectedObjects()

        Object o[] = new Object[1];
        o[0] = new Integer (i);
        return o;
    
public voidprocessEvent(java.awt.AWTEvent e)

        if (e.getID() == MouseEvent.MOUSE_PRESSED) {
            if (itemListener != null) {
                selected = !selected;
                i++;
                itemListener.itemStateChanged (
                    new ItemEvent (this, ItemEvent.ITEM_STATE_CHANGED,
                        getSelectedObjects(),
                        (selected?ItemEvent.SELECTED:ItemEvent.DESELECTED)));
            }
        }
    
public voidremoveItemListener(java.awt.event.ItemListener l)

        itemListener = AWTEventMulticaster.remove (itemListener, l);