Java - Applet - drawArc

The drawArc() method in Java is used to draw an arc or a partial section of an ellipse. It takes six parameters: the x-coordinate and y-coordinate of the top left corner of the bounding rectangle, the width and height of the bounding rectangle, the start angle of the arc in degrees and the sweep angle of the arc in degrees.

Here is an example of how to use the drawArc() method in a Java applet:

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

public class MyArcApplet extends Applet {

    public void paint(Graphics g) {
        // Draw a red arc with a start angle of 0 degrees and a sweep angle of 120 degrees
        g.setColor(Color.RED);
        g.drawArc(50, 50, 100, 100, 0, 120);
        
        // Draw a blue arc with a start angle of 180 degrees and a sweep angle of 180 degrees
        g.setColor(Color.BLUE);
        g.drawArc(150, 50, 100, 100, 180, 180);
        
        // Draw a green arc with a start angle of 90 degrees and a sweep angle of -270 degrees
        g.setColor(Color.GREEN);
        g.drawArc(250, 50, 100, 100, 90, -270);
    }
}

In this example, we create a Java applet that draws three arcs of different colors and sizes on the screen. The drawArc() method is called three times with different arguments to draw each arc. The first two arguments specify the x and y coordinates of the top left corner of the bounding rectangle, the next two arguments specify the width and height of the bounding rectangle, and the last two arguments specify the start angle and sweep angle of the arc in degrees.

Note that a positive sweep angle specifies a counterclockwise rotation, while a negative sweep angle specifies a clockwise rotation.