Saturday, 16 June 2012

Animation program


import java.awt.*;
public class Animation extends Frame
{
int x=0,y=410,z=125;
a()
{
super("Animation
setSize(400,400);
setLayout(new FlowLayout());
setBackground(new Color(255,255,255));
repaint();
setVisible(true);
}
public void paint(Graphics g)
{
int i;
try
{
for(i=0;i<50;i++)
{
g.setColor(new Color(0,180,0));
g.drawLine(x,250,120,200);
g.setColor(new Color(0,180,0));
g.drawLine(y,250,290,200);
Thread.sleep(1000);
x=x+5;
y=y-5;
}
for(i=0;i<6;i++)
{
g.setColor(new Color(255,110,0));
g.fillArc(150,z,100,100,0,360);
Thread.sleep(2000);
g.setColor(new Color(255,255,255));
g.fillArc(150,z,100,100,0,360);
z=z-5;


}
g.setColor(new Color(255,110,0));
g.fillArc(150,z,100,100,0,360);
}
catch(Exception ee)
{
System.out.println(ee);
}
}
public static void main(String a[])
{
new Animation();
}

}

No comments:

Post a Comment