Object[] listeners = tileSelectionListeners.getListenerList(); TileRegionSelectionEvent event = null;
TileLayer region = createTileLayerFromRegion(selection); TileRegionSelectionEvent event = new TileRegionSelectionEvent(this, region); Iterator iterator = tileSelectionListeners.iterator();
    private void fireTileRegionSelectionEvent(Rectangle selection) {        Object[] listeners = tileSelectionListeners.getListenerList();        TileRegionSelectionEvent event = null;        for (int i = listeners.length - 2; i >= 0; i -= 2) {            if (listeners[i] == TileSelectionListener.class) {                if (event == null) {                    TileLayer region = createTileLayerFromRegion(selection);                    event = new TileRegionSelectionEvent(this, region);                }                ((TileSelectionListener) listeners[i + 1]).tileRegionSelected(event);            }        }    }