Enumeration alerts = listeners.elements(); while ( alerts.hasMoreElements() ) { ( (ItemListener) alerts.nextElement() ) .itemStateChanged( alert );
for(ItemListener l:listeners) { l.itemStateChanged(alert);
    public void actionPerformed( ActionEvent event ) {        // Did the worker change their selection?        String curCat = categories.getSelectedItem();        String curItem = items.getSelectedItem();        if ( !curCat.equals(prevCat) || !curItem.equals(prevItem) ) {            // Save the new values.            setPrevSelection( curCat, curItem );            // Are there any listeners?            if ( !listeners.isEmpty() ) {                // Get the Image.                Image image = null;                Image[] array = (Image[]) this.getSelectedObjects();                if ( null != array ) image = array[0];                // Create an ItemEvent for the change.                ItemEvent alert = new ItemEvent                    ( this, event.getID(), image, ItemEvent.ITEM_STATE_CHANGED );                // Alert the listeners.                Enumeration alerts = listeners.elements();                while ( alerts.hasMoreElements() ) {                    ( (ItemListener) alerts.nextElement() )                        .itemStateChanged( alert );                }            } // End have-listeners        } // End selection-changed        // Now exit.        close();    }