/* Simple banner using applet */
import java.awt.*;
import java.applet.*;
/*
<applet code=Banner width=1200 height=600></applet>
*/
public class Banner extends Applet implements Runnable
{
String msg = "... This is a simple banner ...";
Thread t = null;
int state;
boolean stopFlag;
Font f;
public void init()
{
setBackground(Color.green);
setForeground(Color.black);
f=new Font("Arial",Font.BOLD,70);
setFont(f);
}
public void start()
{
t = new Thread(this);
stopFlag = false;
t.start();
}
public void run()
{
char ch;
while(true)
{
try
{
repaint();
Thread.sleep(250);
ch = msg.charAt(0);
msg = msg.substring(1,msg.length());
msg += ch;
if(stopFlag)
break;
}
catch(InterruptedException e) {}
}
}
public void stop()
{
stopFlag = true;
t = null;
}
public void paint(Graphics g)
{
g.drawString(msg,50,300);
}
}
No comments:
Post a Comment