pen.fillOval( left, top, width, height, drawingColor ) pen.invertOval( left, top, width, height ) pen.clearOval( left, top, width, height ) pen.frameOval( left, top, width, height, drawingColor ) pen.invertOvalFrame( left, top, width, height ) pen.clearOvalFrame( left, top, width, height )
Ovals and circles are drawn in Java by specifying a rectangle or square that encloses the desired shape. As a result, the methods for drawing ovals are almost identical to the methods for drawing rectangles. In fact, if you compare the skeletal method invocations for ovals given above to those given for the rectangle drawing primitives you should notice that the only difference is that on each line the word "Rect" has been replaced by "Oval".
Ovals can be framed or filled. In each case, the rectangle containing the oval to be affected is specified by giving the coordinates of its upper left corner and its width and height. An optional color can be specified. Methods for clearing or inverting the frame or contents of an oval are also provided.
An applet illustrating the behavior of the rectangle and oval drawing methods is shown below. It allows you to draw a rectangle with the mouse and to indicate using menus whether to fill or frame an oval or rectangle within that rectangle. A menu is also provided through which the drawing color can be changed. For each shape drawn, the applet displays an appropriate invocation of a drawing primitive that could be used to draw the shape shown.