for (int y = 0; y < myMap.getHeight() && !bFound; y++) { for (int x = 0; x < myMap.getWidth() && !bFound; x++) { ListIterator itr = myMap.getLayers(); while(itr.hasNext()) { MapLayer layer = (MapLayer) itr.next(); Rectangle bounds = layer.getBounds();  if(layer.getTileAt(x,y) == (Tile) searchCBox.getSelectedItem()) { if(currentMatch != null) { if(currentMatch.equals(new Point(x,y))) { continue; } } sl.select(x,y); bFound = true; break; } } } }  if(bFound) myMap.addLayerSpecial(sl);
	public void actionPerformed(ActionEvent e) {		String command = e.getActionCommand();				if(command.equalsIgnoreCase("cancel")) {			myMap.removeLayerSpecial(sl);			this.dispose();		} else if(command.equalsIgnoreCase("find")) {			boolean bFound = false;						if(sl != null) {				myMap.removeLayerSpecial(sl);			} else {				sl = new SelectionLayer(myMap.getWidth(), myMap.getHeight());			}						for (int y = 0; y < myMap.getHeight() && !bFound; y++) {				for (int x = 0; x < myMap.getWidth() && !bFound; x++) {					ListIterator itr = myMap.getLayers();							while(itr.hasNext()) {						MapLayer layer = (MapLayer) itr.next();						Rectangle bounds = layer.getBounds();										if(layer.getTileAt(x,y) == (Tile) searchCBox.getSelectedItem()) {							if(currentMatch != null) {								if(currentMatch.equals(new Point(x,y))) {									continue;								}							}							sl.select(x,y);							bFound = true;							break;						}					}				}			}						if(bFound)				myMap.addLayerSpecial(sl);					} 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);					} else if(command.equalsIgnoreCase("replace all")) {			replaceAll((Tile) searchCBox.getSelectedItem(),(Tile) replaceCBox.getSelectedItem());		}			}