import java.awt.*; import java.awt.event.*; import java.applet.*; public class RectApplet2 extends Applet { public static final int IDEAL_WIDTH = 200; public static final int IDEAL_HEIGHT = 200; public void paint(Graphics g) { g.setColor(Color.BLACK); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(Color.WHITE); for (int x = 0; x < getWidth() / 2; x += 5) { int x1 = (getWidth() / 2) - x; int y1 = (getHeight() / 2) - x; g.drawRect(x1, y1, x * 2, x * 2); } } public static void main(String args[]) { Applet applet = new RectApplet(); Frame frame = new Frame(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); frame.add(applet); frame.setSize(IDEAL_WIDTH, IDEAL_HEIGHT); frame.show(); } }