created 01/22/00; revised 12/10/10
For all of these exercises, use getWidth()
and getHeight()
rather than hard-coding width and height into your code.
For better looking figures, use
fillCircle()
rather than drawCircle()
and
fillRect()
rather than drawRect()
.
Write an applet that displays four circles in a square drawing area. Each circle is centered in one of the four quadrants of the drawing area and each circle is a different color.
Click here to go back to the main menu.
Write an applet that displays a set of three concentric circles of different colors centered in the the applet's drawing area.
Click here to go back to the main menu.
Draw a quadrilateral that connects the center points of the four edges of the applet.
Click here to go back to the main menu.
Draw a large asterisk * in the center of the the applet's drawing area by drawing four lines that intersect in the center. (Harder: draw the * using five short lines that radiate from the center of the applet.)
Click here to go back to the main menu.
Draw an oval that nicely fills the rectangle of the applet.
Click here to go back to the main menu.
Draw five nested rectangles of various colors.
Click here to go back to the main menu.
Draw N nested rectangles, where each rectangle is spaced 5 pixels from its neighbors, no matter what the size of the applet. N is an integer variable that depends on the size of the applet. The larger the applet, the more rectangles are drawn. You will need to use a loop for this.
Click here to go back to the main menu.
End of the Exercises