Ex.
no:05 Shapes Demo
Date:
Aim:
To write a java program to draw Several Shapes in the created windows.
Algorithm:
Step 1: Start the Process
Step 2: Import the program .awt and .applet for using the applet function.
Step 3: Create a class Shape and extends from the Applet and define the function Paint().
Step 4: Under the paint() pass the parameter (Graphics g) by using the object g call the different
functions of applet.
Step 5: Using object g we call drawRect(), drawRound Rect(), drawLine(), drawOval(), fillOvel()
using the suitable coordinates.
Step 6: Display the different shapes in windows.
Step7:The Applet tag </applet> is used to set the width and height for the Applet window.
Step8:Stop the process.
Source code
import [Link].*;
import [Link].*;
import [Link].*;
/*<applet code="Progm5" height=1000 width=1000> </applet>*/
public class Progm5 extends Applet
{
public void init()
{
setBackground([Link]);
setForeground([Link]);
}
public void paint(Graphics g)
{
[Link]("Draw several shapes in a created window",400,50);
[Link]("----------------------------------------------------------",400,60);
[Link]([Link]);
[Link]("[Link]",125,90);
[Link](150,100,250,100);
[Link]("[Link]",125,125);
[Link](150,150,70,40);
[Link](150,150,70,40);
[Link]("[Link] RECTANGLE",125,220);
[Link](150,250,70,40,10,20);
[Link](150,250,70,40,10,20);
[Link]("[Link]",125,315);
[Link](150,340,50,50);
[Link](150,340,50,50);
[Link]("[Link]",125,420);
[Link](125,445,90,80,50,70);
[Link](125,445,90,80,50,70);
}
}
Output:
Result:
Thus the above program has been executed successfully.