//draws a dot and make it move each redraw
//modified from computer insights Arnold UTM
//mbooth 2005 12
//code redone to show solution to exercise 3 in notes

//import section
import javax.swing.*;//gui
import java.awt.*; //application windowing tool
import java.awt.image.*;

class DrawingPanel extends JPanel
{

    //field
	int i;
	int intX,
        intY;//coordinates

    //constructor
	public DrawingPanel()
    {
        setBackground(Color.black);//set the window
		i=0;//initialize counter
		intX=100;//initialize coordinates
		intY=100;
	}

	// overridden method of JPanel,
    // Called each time the screen needs to be repainted
	// g is the pen used to repaint the screen
	public void paintComponent(Graphics g)
    {
		super.paintComponent(g);//overriden paintComponent
		g.setColor(Color.blue);//dot colour
		g.drawString("i="+i,10,10);//display i
		//g.setColor(Color.yellow);//yellow face
		//g.fillOval(intX+i-5, intY+i-10, 40,40);
		g.setColor(Color.white);//colour of dots
		g.fillOval(intX+i,intY+i, 10, 10);//fill dot
		//g.fillOval(intX+20+i, intY+i, 10, 10);//fill another dot
		i++; //increment counter
	} //end of paintComponent
} //end  of class