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

public
class FlowString extends Applet implements Runnable
{
   int x, y, j;
   String napis;
   Font fontTimesRoman;
   Image img;
   Graphics gDC, mDC;
   public void init()
   {
      x = 0;
      y = 180;
      j = 1;
      napis = new String ("HOP HOP");
      fontTimesRoman = new Font ("TimesRoman", Font.BOLD, 36);
      img = createImage (600, 400);
      mDC = img.getGraphics();
      gDC = getGraphics();
   }
   public void start()
   {
      Thread thread = new Thread (this);
      thread.start();
   }
   public void run()
   {
      while (true){
         x += j;
         if ((j == 1) && (x > 530)){
            j = -1;
         }
         else if (x <= 0){
            j = 1;
         }
         try{
            Thread.sleep(1);
         }
         catch (InterruptedException e){
         }
         mDC.clearRect(0, 0, 600, 400);
         mDC.setColor (Color.blue);
         mDC.setFont (fontTimesRoman);
         mDC.drawString (napis, x, y);
         gDC.drawImage (img, 0, 0, this);
      }
   }
}
