/** * Notify all listeners that have registered interest for notification on the 'update status' event type. The event * instance is lazily created using the parameters passed into the fire method. */ protected void fireUpdateState() { if (getEventListenerList() == null) { return; } // Guaranteed to return a non-null array Object[] listeners = getEventListenerList().getListenerList(); // Process the listeners last to first, notifying // those that are interested in this event CommandEvent commandEvent = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == CommandListener.class || listeners[i] == CommandStateListener.class) { // Lazily create the event: if (commandEvent == null) { commandEvent = new CommandEvent(this, null, null, null); } ((CommandStateListener) listeners[i + 1]).updateState(commandEvent); } } }