Java Blog

 
 
 
import java.awt.*;
import java.applet.*;

public class simpleBanner extends Applet implements Runnable
{
      String msg=\" A Simple Moving Banner. \";
      Thread t=null;
      int state;
      boolean stopflag;

      public void init()
      {
           setBackground(Color.yellow);
           setForeground(Color.red);
      }

      public void start()
      {
           t = new Thread(this);
           stopflag=false;
           t.start();
     }

     public void run()
     {
          char ch;
          for(;;){
             try{
                 repaint();
                 Thread.sleep(250);
                 ch=msg.charAt(0);
                 msg=msg.substring(1,msg.length());
                 msg=msg+ch;
                 if(stopflag)
                     break;
            }catch(InterruptedException e) {}
        }
     }

     public void stop()
     {
         stopflag=true;
         t=null;
     }

     public void paint(Graphics g)
     {
          g.drawString(msg,50,30);
          showStatus(\"Simple Banner\");
    }

}

 
 
Didn't find what you were looking for? Find more on An applet of displaying simple moving banner