import java.awt.*;
import java.applet.*;

public class RText1 extends Applet implements Runnable
{
 String teksti[] = new String[4];
 int ftkoko, a, x, y, bgcolor;
 Thread th;
 int ftr = 255, ftg = 0, ftb = 0;
 Font fonti;
 
 public void init()
 {
  teksti[0] = getParameter("teksti[0]");
  teksti[1] = getParameter("teksti[1]");
  teksti[2] = getParameter("teksti[2]");
  teksti[3] = getParameter("teksti[3]");
  ftkoko = Integer.valueOf(getParameter("ftkoko")).intValue();
  bgcolor = Integer.valueOf(getParameter("bgcolor")).intValue();
  setBackground(new Color(bgcolor));	
 }
 public void start()
 {
  if (th == null) {
  th = new Thread(this);
  th.start(); }
  }

  public void stop()
  {
   th = null;
   }

  public void run()
  {
   while (true)
   {
    super.repaint();
   try {				// viive
     th.sleep(2000); }
     catch (InterruptedException e) {}
   
    }
   }

 public void paint(Graphics g)
 {
  fonti = new Font("Arial",Font.BOLD,ftkoko);
  g.setFont(fonti);
  
  ftr = (int)(Math.random()*255);	// satunnaiset värit
  ftg = (int)(Math.random()*255);
  ftb = (int)(Math.random()*255);
  g.setColor(new Color(ftr, ftg, ftb));
  
   a++;					// vaihda teksti[a]
   if (a == 4)
    a = 0;
    showStatus(teksti[a]); 
    x = (bounds().width - getFontMetrics(fonti).stringWidth(teksti[a]))/2;
       //keskitä tekstiä
    y = (int)(bounds().height/1.5);   
     g.drawString(teksti[a], x, y);  // tulostaa teksti  
	
  }
}
