Draw Circles and Ellipses in Java Applet

In Java, 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 actually the coordinates of an enclosing rectangle.


import java.awt.*;
import java.applet.*;
public class circle extends Applet
 public void paint(Graphics g)

         <applet code = "circle.class" width = "480" height = "360"></applet>

Draw Circles and Ellipses  in Java Applet

Recommended Posts:

Advanced Java
    1. Difference between Local Applet and Remote Applet
    2. Applet Life Cycle in Java
    3. Difference Between Applet and Application
    4. Creating an Executable Applet in Java
    5. Displaying Numerical values in Applet
    6. An Applet Program to Add Two Numbers
    7. Event Handling in Applet
    8. AWT Classes in Java
    9. Draw a line and rectangle in Java Applet
    10. Draw Circles and Ellipses in Java Applet
    11. Draw Arc in Java Applet
    12. Develop an Applet for Drawing a Human Face
    13. Draw a Polygon in Java Applet
    14. Draw Line Graph in Java Applet
    15. Java Applet Program to Draw National Flag
    16. Demonstrate to Draw Bar Charts in Java