Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Logo Java source code
#1

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;
  }
}
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Powered By MyBB, © 2002-2024 iAndrew & Melroy van den Berg.