Gramin Technical And Management Campus
Department Of Computer Engineering
                                                 Subject/code: JPR/22412
Name: Thadke Priyanka               Batch: A         Roll No: 85
Practical No:29
Aim:- Writw a program to create animated sgape using graphics and applet.
You may use following shapes.
Aim : write a program to implement an applet to draw basic animated shapes.
Program Code:
import java.awt.*; import
java.applet.*; public class Ap
extends Applet
 public void paint(Graphics g)
        g.drawRect(25,40,100,50);
        g.fillRect(45,50,100,50);
/*<applet code="Ap.class" width="400" height="200"></applet>*/
Output:
Exercise:-
Q.1)Develop a program to draw a polygon.
Program Code:
import java.awt.*;
import java.applet.*;
public class Ap extends Applet
{
public void paint(Graphics g)
    {
        int x[]={20,35,50,65,80,95};
int y[]={60,105,105,110,95,35};
 g.drawPolygon(x,y,6);
    }
}
/*<applet code="Ap.class" width="400" height="200"></applet>*/
Output:
Aim : Develop an applet for drawing a human face.
Program Code:
import java.awt.*;
import java.applet.*; public
class Ap extends Applet
{
 public void paint(Graphics g)
        {
        g.setColor(Color.yellow) ;
        g.fillOval(20,20,150,150);
        g.setColor(Color.black);
        g.fillOval(50,60,15,25);
        g.fillOval(120,60,15,25);
    int x[]={95,85,106,95};
int y[]={85,104,104,85};
        g.drawPolygon(x,y,4);
    }
}
/*<applet code="Ap.class" width="400" height="200"></applet>*/
Output: