@Override
	public void mouseClicked(MouseEvent e) {
		BufferedImage image = canvas.getImg();
		int replaceColor = canvas.getColor().getRGB();
		int targetColor = image.getRGB(e.getX(), e.getY());
		if (targetColor != replaceColor) {
			Stack<Point> stack = new Stack<Point>();
			stack.push(new Point(e.getX(), e.getY()));
			Point point;
			while (!stack.isEmpty()) {
				point = stack.pop();

				if (image.getRGB(point.x, point.y) == targetColor) {
					image.setRGB(point.x, point.y, replaceColor);

					if (point.x + 1 < image.getWidth()) {
						stack.push(new Point(point.x + 1, point.y));
					}
					if (point.x - 1 >= 0) {
						stack.push(new Point(point.x - 1, point.y));
					}
					if (point.y + 1 < image.getHeight()) {
						stack.push(new Point(point.x, point.y + 1));
					}
					if (point.y - 1 >= 0) {
						stack.push(new Point(point.x, point.y - 1));
					}
				}
			}
		}
		canvas.repaint();

	}