Canvas Example (Cont)
public void paint(Graphics g) {
int last_x = 0; int last_y = 0;
Dimension dim = getSize();
int width = dim.width; int height = dim.height;
while (last_x <= height) {
g.drawLine(0, last_x, width, last_x); // draw the horizontal lines
last_x = last_x + horizontal_spacing;
while (last_y <= width) {
g.drawLine(last_y, 0, last_y, height); // draw the vertical lines
last_y = last_y + vertical_spacing;