Draw Circles and Ellipses in Java Applet

In Java, the Graphics class doesn’t have any method for circles or ellipses. However, the drawOval() method can be used to draw a circle or an ellipse. Ovals are just like a rectangle with overly rounded corners.

The drawOval() method takes four arguments: the first two represent the top-left corner of the imaginary rectangle and the other two represent the width and height of the oval itself.

Note: If the width and height are the same, the oval becomes a circle. The oval’s coordinates are the coordinates of an enclosing rectangle.

Example:

 

Output:
Draw Circles and Ellipses in Java Applet