Java - Applet - fillOval

The fillOval() method in Java applets is used to draw a filled oval with the specified coordinates and dimensions. It takes four parameters:

  • x : the x-coordinate of the upper left corner of the oval
  • y : the y-coordinate of the upper left corner of the oval
  • width : the width of the oval
  • height : the height of the oval

Here's an example of how to use the fillOval() method in a Java applet:

import java.awt.Color;
import java.awt.Graphics;
import java.applet.Applet;

public class MyOvalApplet extends Applet {
    public void paint(Graphics g) {
        // Set the color to red
        g.setColor(Color.RED);

        // Draw a filled oval with a black border
        g.fillOval(50, 50, 100, 100);
    }
}

In this example, we've created a new Java applet class called MyOvalApplet that extends the Applet class. The paint() method is overridden to draw an oval with the fillOval() method. The color of the oval is set to red using the setColor() method. The fillOval() method is then called with the parameters 50, 50, 100, and 100, which specify the x-coordinate, y-coordinate, width, and height of the oval, respectively.