Program to draw Arcs on Applet
This program demonstrates how to draw and fill arcs.
The drawArc( ) method draws the outline of a circular or elliptical arc covering the specified rectangle. Angles are interpreted such that 0 degrees is at the 3 o'clock position. Arc angle is also known as sweep angle. A positive value of angle indicates a counter-clockwise rotation while a negative value indicates a clockwise rotation. The syntax for drawArc( ) is given below:
void drawArc (int x, int y, int width, int height, int startAngle, int arcAngle)
The fillArc( ) method fills a circular or elliptical arc covering the specified rectangle. Angles are interpreted such that 0 degrees is at the 3 o'clock position. A positive value of angle indicates a counter-clockwise rotation while a negative value indicates a clockwise rotation. The syntax for fillArc( ) is given below:
PROGRAM
OUTPUT
C:\>javac DrawArcs.java
C:\>appletviewer DrawArcs.java
void fillArc (int x, int y, int width, int height, int startAngle, int arcAngle)
PROGRAM
// Draw Arcs
import java.awt.*;
import java.applet.*;
public class DrawArcs extends Applet
{
public void paint(Graphics g)
{
g.drawArc(10, 40, 70, 70, 0, 75);
g.fillArc(100, 40, 70, 70, 0, 75);
g.drawArc(10, 100, 70, 80, 0, 175);
g.fillArc(100, 100, 70, 90, 0, 270);
g.drawArc(200, 80, 80, 80, 0, 180);
}
}
/*
<applet code="DrawArcs" width=300 height=200>
</applet>
*/
OUTPUT
C:\>javac DrawArcs.java
C:\>appletviewer DrawArcs.java