import objectdraw.*; import java.awt.*; // A program that uses the translate method to draw a // grid of thick black lines on the canvas public class DrawingGrid2 extends FrameWindowController{ private static final int THICKNESS = 5; // Thickness of FilledRects // Locations of the next two rectangles to draw private Location verticalCorner, horizontalCorner; // Set coordinates to position first pair of rectangles at upper // left corner of the canvas public void begin() { horizontalCorner = new Location(0, 0); verticalCorner = horizontalCorner; } public void onMousePress(Location point) { new FilledRect(verticalCorner, THICKNESS, canvas.getHeight(), canvas); new FilledRect(horizontalCorner, canvas.getWidth(), THICKNESS, canvas); verticalCorner.translate(2 * THICKNESS, 0); horizontalCorner.translate(0, 2 * THICKNESS); } }