package com.github.javaccsf2016.drawboard;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;


public class DrawBoardDisplay extends JPanel {
	private static Color color = Color.black;
	private ArrayList<Point> pointList;
	public DrawBoardDisplay() {
			setBackground(Color.PINK);
			this.addMouseListener(new MouseMovementListener());			
			pointList = new ArrayList<>();

			}
			
	public static void main(String args[]) {
		EventQueue.invokeLater(new Runnable() {
		public void run() {
				JFrame frame = new JFrame("Draw On Me");
				frame.setSize(800,600);
				DrawBoardDisplay drawingPanel = new DrawBoardDisplay();
				ControlPanel controlPanel = new ControlPanel(drawingPanel);
				frame.getContentPane().add(drawingPanel, BorderLayout.CENTER);
				frame.getContentPane().add(controlPanel, BorderLayout.SOUTH);
				frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				frame.setVisible(true);
			}
		   });
	}

	public class MouseMovementListener extends MouseAdapter{
		@Override
		public void mouseMoved(MouseEvent event) {
			Point mostRecentPosition = event.getPoint();
			pointList.add(mostRecentPosition);
			repaint();
			
		}
	}

	@Override
	public void paintComponent(Graphics pen) {
		super.paintComponent(pen);
		pen.setColor(color.black);

		for(Point p : pointList) {
			int x = (int) p.getX();
			int y = (int) p.getY();
			pen.drawOval((int)x, (int)y, 100, 100);
			repaint();
			
		}
	}

	public void redPen() {
		color = Color.RED; 	}

	public void bluePen() {
		color = Color.BLUE;	}

	public void greenPen() {
		color = Color.GREEN;	}

	public void eraser() {
		color = Color.PINK;	}

	public void clearAll() {
		pointList.clear();}

}

@@ -171,16 +171,44 @@
 Panel %7B%0A
+%09private boolean isDrawing;%0A
 %09private
@@ -279,16 +279,20 @@
 ntList;%0A
+%09%0A%09%0A
 %09public 
@@ -313,16 +313,36 @@
 ay() %7B%0A%09
+%09isDrawing = false;%0A
 %09%09setBac
@@ -364,17 +364,16 @@
 INK);%0A%09%09
-%09
 this.add
@@ -377,16 +377,22 @@
 addMouse
+Motion
 Listener
@@ -422,20 +422,63 @@
 ner());%09
+%0A
 %09%09
+this.addMouseListener(new MouseListener());
 %0A
-%09
 %09%09pointL
@@ -502,19 +502,16 @@
 st%3C%3E();%0A
-%0A%09%09
 %09%7D%0A%09%09%09%0A%09
@@ -1047,16 +1047,272 @@
   %7D);%0A%09%7D
+%0A%09%0A%09public class MouseListener extends MouseAdapter %7B%0A%09%09public void mouseClicked(MouseEvent event) %7B%0A%09%09%09if(isDrawing) %7B%0A%09%09%09%09isDrawing = false;%0A%09%09%09%7D else %7B%0A%09%09%09%09isDrawing = true;%0A%09%09%09%7D%0A%09%09%09System.out.println(pointList);%0A%09%09%09System.out.println(isDrawing);%0A%09%09%7D%0A%09%7D
 %0A%0A%09publi
@@ -1420,16 +1420,36 @@
 vent) %7B%0A
+%09%09%09if(isDrawing) %7B%0A%09
 %09%09%09Point
@@ -1491,16 +1491,17 @@
 t();%0A%09%09%09
+%09
 pointLis
@@ -1527,16 +1527,17 @@
 ition);%0A
+%09
 %09%09%09repai
@@ -1534,32 +1534,36 @@
 %0A%09%09%09%09repaint();%0A
+%09%09%09%7D
 %09%09%09%0A%09%09%7D%0A%09%7D%0A%0A%09@Ov
@@ -1662,22 +1662,16 @@
 or(color
-.black
 );%0A%0A%09%09fo
@@ -1756,20 +1756,20 @@
 %0A%09%09%09pen.
-draw
+fill
 Oval((in
@@ -1787,14 +1787,12 @@
 , 10
-0
 , 10
-0
 );%0A%09

fix listener