FileDocCategorySizeDatePackage
DrawCanvas.javaAPI DocExample767Thu Jul 29 15:21:22 BST 1999None

DrawCanvas

public class DrawCanvas extends MouseableCanvas

Fields Summary
int[]
mx
int[]
my
int
counter
static final int
ARRAYSIZE
Constructors Summary
public DrawCanvas()

	
	 
	
		mx = new int[ARRAYSIZE ];
		my = new int[ARRAYSIZE ];
	
Methods Summary
public voidmousePressed(java.awt.event.MouseEvent e)

		mx[counter] = e.getX();
		my[counter] = e.getY();
		System.out.println("x: " + mx[counter] + "  y: " + my[counter]);
		Graphics g = this.getGraphics();
		if(counter > 0)
			g.drawLine(mx[counter-1], my[counter-1], mx[counter], my[counter]);
		counter++;
		if(counter > ARRAYSIZE-1) counter = 0;
	
public voidpaint(java.awt.Graphics g)

		for(int i = 0; i < counter-1; i++)
		{
			g.drawLine(mx[i], my[i], mx[i+1], my[i+1]);
		}