30-08-2011, 12:31 PM
Code:
import java.awt.*;
import java.applet.*;
/*
<applet code=Logo width=400 height=400 >
</applet>
*/
public class Logo extends Applet implements Runnable
{
Image img;
Thread thd = null;
int i;
int imgWidth = 359;
int imgHeight = 121;
public void run()
{
img = getImage(getCodeBase(), "ASHTAAL.gif");
if (img != null)
{
i=imgHeight;
repaint();
while (true)
{
try {Thread.sleep(1000);} catch (InterruptedException e){}
i=0;
while (i<imgHeight)
{
repaint();
try {Thread.sleep(50);} catch (InterruptedException e){}
i+=4;
}
}
}
}
public void update(Graphics g)
{
if (img != null)
{
g.clipRect(0, 0, imgWidth, i);
g.drawImage(img, 0, i - imgHeight, null);
}
else
g.drawString("Image Not Found",50,50);
}
public void start()
{
if (thd == null)
{
thd = new Thread(this);
thd.start();
}
}
public void stop()
{
thd = null;
}
}