/* afftab.java - jpq - 29/08/00 - 14/09/00 - 07/05/04 jdk1.2
 * modification le 06/02/18 : prise en compte que gtab est static
 */

import java.awt.*;
import java.applet.*;

public class afftab extends java.applet.Applet implements Runnable {
  static final long serialVersionUID = 180206L;
  Thread t;
  TextArea ta;

  public void init ()
  { setFont (new Font ("Arial", Font.PLAIN, 10));
    setBackground (Color.white);
    add (ta = new TextArea ("", 2, 40, TextArea.SCROLLBARS_HORIZONTAL_ONLY));
  }

//----------------------------------------------------------------------------

  public void start ()
  { if (t == null) { t = new Thread (this); t.start (); } }

  public void stop ()
  { t = null; }

  public void run ()
  { while (true) { if (gtab.change) { gtab.change = false; repaint (); }
                   try { Thread.sleep (100); } catch (Exception e) { } 
                 }
  }

  public void update (Graphics g)
  { paint (g); }

//----------------------------------------------------------------------------

  public void paint (Graphics g)
  { g.setColor (Color.lightGray);
    g.fillRect (0, 0, getSize().width, getSize().height);
    String s = "";
    if (gtab.tableau != null)
    { if (gtab.dim > gtab.tableau.length) gtab.dim = gtab.tableau.length;
      for (int i = 0; i < gtab.dim; i ++) s = s + Integer.toString (gtab.tableau [i]) + "\t";
      ta.setText (s);
    }
  }

}
////////////////////////////////////////////////////////////////////////////////
class gtab
{ static boolean change;
  static int dim;
  static int [] tableau;

  static public void maj (int d, int [] tab)
  { dim = d;
    tableau = tab;
    change = true;
  }

}
