Academic Java    Java Tutorial  >  Applets  >  circles are arcs

circles are arcs Example

Java circles are arcs EXAMPLE output Arcs with a sweep angle of 360 degrees are circles.

The first four parameters of drawArc() and fillArc() specify a rectangle with x, y coordinates at top-left of it. The center of the rectangle is the center of the arc. The next two are startAngle and arcAngle. The resulting arc begins at startAngle and extends for arcAngle degrees. Angles are interpreted such that 0 degrees is at the 3 o'clock position. Positive values indicate counter-clockwise rotation, negative values go clockwise.

Three circles are drawn.
// drawArc() fillArc() Example 2
import java.awt.*;
import javax.swing.*;

class DrawArcExample2 extends JApplet {

   @Override public void paint(Graphics g) {

      super.paint(g);

      g.setColor(Color.cyan);
      g.fillArc(100,100,100,100,0,360);

      g.setColor(Color.blue);
      g.drawArc(100,100,100,100,0,360);
      g.drawArc(125,125,50,50,0,360);

   }
}


* drawArc() fillArc() Examples