Banner

import java.awt.*;
import java.applet.*;
public class Banner extends Applet implements Runnable{
String str="This is a Banner.........";
Thread t;
boolean b;
public void init()
{
setBackground(Color.gray);
setBackground(Color.yellow);
}
public void start()
{

t=new Thread(this);
b=false;
t.start();
}
public void run()
{
char ch;
for(;;)
{
try
{
repaint();
Thread.sleep(250);
ch=str.charAt(0);
str=str.substring(1,str.length());
str=str+ch;
}
catch(InterruptedException e)
{
}

}
}
public void paint(Graphics g)
{
g.drawRect(100, 80, 120,20);
g.setColor(Color.yellow);
// g.fillRect(100, 100, 50, 50);
g.setColor(Color.red);
g.drawString(str, 100, 95);
}
}



No comments:

Post a Comment