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:
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



Comments

Popular posts from this blog

Program to define a class 'employee' with data members as empid, name and salary. Accept data for 5 objects using Array of objects and print it.

Define a class Student with four data members such as name, roll no.,sub1, and sub2. Define appropriate methods to initialize and display the values of data members. Also calculate total marks and percentage scored by student.

Program to draw Smiley in Applet