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

public class PegGameApplet extends Applet implements Runnable {

  PegGraphics pegG;
  
  public void init() {
    setLayout(new BorderLayout());
    try {
      if (getParameter("bgcolor")!=null) {
        setBackground(new Color(Integer.parseInt(getParameter("bgcolor"), 16)));
      }
    }
    catch (NumberFormatException e) { System.out.println(e); }
    showStatus("Creating game tree...");
    // let the thread continue to paint screen, etc
    // while we're still loading the game tree
    Thread t = new Thread(this);
    t.start();
  }
  
  public void run() {
    pegG = new PegGraphics();
    add(pegG);
    invalidate();
    validate();
    repaint();
    showStatus("Done.");
  }
  
  public void paint(Graphics g) {
    if (pegG==null) {
      g.drawString("Loading...", 30, 30);
    }
  }
  
}