@Override
	public void mouseClicked(MouseEvent m) {
		
		if(m.getButton() == MouseEvent.BUTTON3) {
			
			int x1 = m.getX();
			int y1 = m.getY();
			
			for(int i = 0; i < rects.size(); i++) 
				if(x1 >= rects.get(i).x && x1 <= rects.get(i).width + rects.get(i).x &&
				   y1 >= rects.get(i).y && y1 <= rects.get(i).height + rects.get(i).y)
					rects.remove(i);
			
			paintComponent(getGraphics());
		}
		
		if(m.getButton() == MouseEvent.BUTTON2) {

			try {
				
				FileWriter writer = new FileWriter(new File("an" + anNum++));

				for(Rectangle e : rects)
					writer.write(e.x + " " + e.y + " " + e.width + " " + e.height + " ");
				
				rects = new ArrayList<Rectangle>();
				
				writer.close();
				
			} catch (IOException e) {
				
				e.printStackTrace();
				
			}
		
		}
		
	}