ListIterator itr = myMap.getLayers(); while(itr.hasNext()) { MapLayer layer = (MapLayer) itr.next(); if(layer.getTileAt(currentMatch.x,currentMatch.y) == (Tile) searchCBox.getSelectedItem()) { layer.setTileAt(currentMatch.x,currentMatch.y, (Tile) replaceCBox.getSelectedItem()); break; } }  find((Tile)searchCBox.getSelectedItem());
	public void actionPerformed(ActionEvent e) {		String command = e.getActionCommand();				if(command.equalsIgnoreCase("close")) {			myMap.removeLayerSpecial(sl);			this.dispose();		} else if(command.equalsIgnoreCase("find")) {			if(searchCBox.getSelectedItem() instanceof Tile) {				find((Tile)searchCBox.getSelectedItem());			}		} else if(command.equalsIgnoreCase("find all")) {			if(sl != null) {				myMap.removeLayerSpecial(sl);			}						sl = new SelectionLayer(myMap.getWidth(), myMap.getHeight());			ListIterator itr = myMap.getLayers();					while(itr.hasNext()) {				MapLayer layer = (MapLayer) itr.next();				Rectangle bounds = layer.getBounds();				for (int y = 0; y < bounds.height; y++) {						for (int x = 0; x < bounds.width; x++) {							if(layer.getTileAt(x,y) == (Tile) searchCBox.getSelectedItem()) {								sl.select(x,y);							}						}				}			}			myMap.addLayerSpecial(sl);			myMap.touch();					} else if(command.equalsIgnoreCase("replace all")) {			if(!(searchCBox.getSelectedItem() instanceof TileSet) && !(replaceCBox.getSelectedItem() instanceof TileSet))				replaceAll((Tile) searchCBox.getSelectedItem(),(Tile) replaceCBox.getSelectedItem());		} else if(command.equalsIgnoreCase("replace")) {			if(!(searchCBox.getSelectedItem() instanceof TileSet) && !(replaceCBox.getSelectedItem() instanceof TileSet)) {				if(currentMatch == null) {					find((Tile)searchCBox.getSelectedItem());				}								//TODO: replace tile on correct layer			}		}			}