Java - Applet - drawOval

The drawOval() method of the Graphics class in Java Applet is used to draw an oval shape on the screen. It takes four arguments as parameters, which are the X and Y coordinates of the top-left corner of the oval, and the width and height of the oval.

Here's an example code that demonstrates the usage of the drawOval() method:

import java.applet.*;
import java.awt.*;

public class MyOval extends Applet {
   public void paint(Graphics g) {
      g.drawOval(50, 50, 100, 80);
   }
}

In this example, we create an applet named MyOval. In the paint() method, we use the drawOval() method to draw an oval shape on the screen with the top-left corner at the point (50, 50), a width of 100 pixels, and a height of 80 pixels.

The drawOval() method can be used to draw any size and shape of ovals on the screen. By changing the parameters of the method, we can draw ovals of different sizes and positions.

Here's another example that demonstrates the usage of the drawOval() method to draw multiple ovals of different sizes and positions:

import java.applet.*;
import java.awt.*;

public class MyOval extends Applet {
   public void paint(Graphics g) {
      g.drawOval(50, 50, 100, 80);
      g.drawOval(150, 100, 80, 120);
      g.drawOval(250, 150, 60, 60);
   }
}

In this example, we draw three ovals of different sizes and positions. The first oval has the top-left corner at the point (50, 50) and a width of 100 pixels and a height of 80 pixels. The second oval has the top-left corner at the point (150, 100) and a width of 80 pixels and a height of 120 pixels. The third oval has the top-left corner at the point (250, 150) and a width and height of 60 pixels.