FileDocCategorySizeDatePackage
Grids.javaAPI DocExample1348Sat Nov 25 12:55:08 GMT 2000None

GridsCanvas

public class GridsCanvas extends Canvas
Program to draw grids.
author
Ian Darwin, ian@darwinsys.com

Fields Summary
int
width
int
height
int
rows
int
cols
Constructors Summary
GridsCanvas(int w, int h, int r, int c)

		setSize(width=w, height=h);
		rows = r;
		cols = c;
	
Methods Summary
public voidpaint(java.awt.Graphics g)

		int i;
		width = getSize().width;
		height = getSize().height;
	
		// draw the rows
		int rowHt = height/(rows);
		for (i = 0; i < rows; i++)
			g.drawLine(0, i*rowHt, width, i*rowHt);

		// draw the columns
		int rowWid = width/(cols);
		for (i = 0; i < cols; i++)
			g.drawLine(i*rowWid, 0, i*rowWid, height);