1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
/* Draw Arc in Applet Window Example This java example shows how to draw arc in an applet window using drawArc method of Graphics class. It also shows how to draw a filled arcs using fillArc method of Graphics class. */ /* <applet code="DrawOvalsExample" width=500 height=500> </applet> */ import java.applet.Applet; import java.awt.Color; import java.awt.Graphics; public class DrawArcExample extends Applet{ public void paint(Graphics g){ //set color to red setForeground(Color.red); /* * to draw an arc in an applet window use, * void drawArc(int x1,int y1, int width, int height,int startAngle, int arcAngle) * method. * * This method draws an arc of specified width and * height at (x1,y1) */ //this will draw an arc of width 50 & height 100 at (10,10) g.drawArc(10,10,50,100,10,45); /* * To draw a filled arc use * fillArc(int x1,int y1, int width, int height,int startAngle, int arcAngle) * method of Graphics class. */ //draw filled arc g.fillArc(100,10,100,100,0,90); } } |
Example Output
Add Comment