PROGRAM5
PROGRAM5
Write a Java Program to draw several shapes in the created windows. Applet
Program.
/*
Syntax for Methods used in this program
To draw Oval:
drawOval(int x, int y, int width, int height)
To change Pen Color:
setColor(Color c)
To color the Oval:
fillOval(int x, int y, int width, int height)
To draw rectangle:
drawRect(int x, int y, int width, int height)
To draw line:
drawLine(int x1, int y1, int x2, int y2)
To draw arc:
drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
*/
SOURCE CODE
import java.awt.*;
import java.applet.*;
public class PL5 extends Applet
{
public void paint(Graphics g)
{
g.setFont(new Font("Calibri", Font.BOLD,30));
g.drawString("Different Shapes in Applet", 20, 20);
g.drawOval(50,50,80,100);
g.setColor(Color.RED);
g.fillOval(50,50,80,100);
g.drawRect(150,150,120,100);
g.drawLine(270,270,350,350);
g.drawArc(60,280,100,80,180,180);
}
}
/* <applet code="PL5.class" width="400" height="400">
</applet>
*/
PROGRAM-5-OUTPUT
Compile :
Javac PL5.java
RUN:
appletviewer PL5.java