Drawing rectangles is simple. Start with a Graphics object g and call its drawRect(int left, int top, int width, int height) method. As the variable names suggest, the first int is the left hand side of the rectangle, the second is the top of the rectangle, the third is the width and the fourth is the height. This is in contrast to some API's where the four sides of the rectangle are given.
Program 12.1 uses drawRect to draw a rectangle around the sides of an applet.
The source code
Copyright 1996 Elliotte Rusty Harold