void drawOval(inttop, intleft, intwidth, intheight)
void fillOval(inttop, intleft, intwidth, intheight)
The ellipse is drawn within a bounding rectangle whose upper-left corner is specified by
top,leftand whose width and height are specified bywidthandheight.To draw a circle, specify
a square as the bounding rectangle.
The following program draws several ellipses:
// Draw Ellipses
import java.awt.*;
import java.applet.*;
/*
<applet code="Ellipses" width=300 height=200>
</applet>
*/
public class Ellipses extends Applet {
public void paint(Graphics g) {
g.drawOval(10, 10, 50, 50);
g.fillOval(100, 10, 75, 50);
g.drawOval(190, 10, 90, 30);
g.fillOval(70, 90, 140, 100);
}
}
Sample output from this program is shown here:
Drawing Arcs
Arcs can be drawn withdrawArc( )andfillArc( ), shown here:
void drawArc(inttop, intleft, intwidth, intheight, intstartAngle,
intsweepAngle)
void fillArc(inttop, intleft, intwidth, intheight, intstartAngle,
intsweepAngle)
Chapter 23: Introducing the AWT: Working with Windows, Graphics, and Text 679