// Graphic1.java import java.awt.*; public class Problem5 extends LabFrame { public void paint(Graphics g) { int x, y; int step = 40; int color = 0; y = 0; while (y < 400) { x = 0; while (x < 400) { // Alternate the color if (color == 0) { g.setColor(Color.red); color = 1; } else { g.setColor(Color.black); color = 0; } g.fillRect(x, y, step, step); x = x + step; } y = y + step; // Alternate the color at the end of the row, too. if (color == 0) { g.setColor(Color.red); color = 1; } else { g.setColor(Color.black); color = 0; } } } public static void main(String[] args) { LabFrame f = new Problem5(); f.setSize(400, 400); f.setVisible(true); } }