/** * Notify all listeners that have registered as ActionListeners if the * selected item has changed * * @see EventListenerList */ protected void fireActionEvent() { if (!firingActionEvent) { // Set flag to ensure that an infinite loop is not created firingActionEvent = true; ActionEvent e = null; // Guaranteed to return a non-null array Object[] listeners = getListenerList(); // Process the listeners last to first, notifying // those that are interested in this event for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ActionListener.class) { if (e == null) e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, getActionCommand()); ((ActionListener) listeners[i + 1]).actionPerformed(e); } } firingActionEvent = false; } }