06-04-2011, 01:22 PM
Code:
import java.awt.*;
import java.applet.*;
//<applet code=Movingb width=100 height=100></applet>
public class Movingb extends Applet implements Runnable
{
String s="MOVING BANNER";
Thread t=null;
boolean flag;
public void init()
{
setBackground(Color.red);
setForeground(Color.blue);
}
public void start()
{
t=new Thread(this);
flag=false;
t.start();
}
public void run()
{
char ch;
for(; ;)
try
{
repaint();
Thread.sleep(1000);
ch=s.charAt(0);
s=s.substring(1,s.length());
s=s+ch;
if(flag==true)
break;
}
catch(InterruptedException ie)
{
}
}
public void stop()
{
flag=true;
t=null;
}
public void paint(Graphics g)
{
g.drawString(s,200,200);
}
}