import objectdraw.*; import java.awt.*; // A program that draws a grid of thick black lines // on the canvas public class DrawingGrid1 extends FrameWindowController { private static final int THICKNESS = 5; // Thickness of FilledRects // Coordinates of the next two rectangles to draw private int verticalCornerX, horizontalCornerY; // Set coordinates to position first pair of rectangles at upper // left corner of the canvas public void begin() { horizontalCornerY = 0; verticalCornerX = horizontalCornerY; } // Draw a pair of rectangles and move coordinates so that the next // pair of rectangles will appear further down and to the right public void onMousePress(Location point) { new FilledRect(verticalCornerX, 0, THICKNESS, canvas.getHeight(), canvas); new FilledRect(0, horizontalCornerY, canvas.getWidth(), THICKNESS, canvas); verticalCornerX = verticalCornerX + 2 * THICKNESS; horizontalCornerY = horizontalCornerY + 2 * THICKNESS; } }