标签:nts objects void red etl cal turn table selected
An object wishing to fire item events must implement ItemSelectable
. This example shows typical code that an object must implement to fire item events. When an item event is to be fired, fireItemEvent()
should be called.
public class MyComponent implements ItemSelectable { protected EventListenerList listenerList = new EventListenerList(); public Object[] getSelectedObjects() { return selectedObjects; } public void addItemListener(ItemListener l) { listenerList.add(ItemListener.class, l); } public void removeItemListener(ItemListener l) { listenerList.remove(ItemListener.class, l); } // If the item is selected, sel should be true. void fireItemEvent(Object item, boolean sel) { ItemEvent evt = new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, item, sel ? ItemEvent.SELECTED : ItemEvent.DESELECTED); // Get list of listeners Object[] listeners = listenerList.getListenerList(); // Send event to all listeners for (int i=0; i<listeners.length-2; i+=2) { if (listeners[i] == ItemListener.class) { ((ItemListener)listeners[i+1]).itemStateChanged(evt); } } } }
Related Examples |
标签:nts objects void red etl cal turn table selected
原文地址:https://www.cnblogs.com/borter/p/9575403.html