import java.awt.*; import java.awt.event.*; import java.applet.*; public class RectApplet 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); g.drawRect(10, 10, 100, 100); } 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(); } }