GridsCanvaspublic class GridsCanvas extends Canvas
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 void | paint(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);
|
|