home *** CD-ROM | disk | FTP | other *** search
/ Java 1996 August / Java - Summer 1996.iso / rockridge / applet / anatomy / classes / Bad.java < prev    next >
Encoding:
Java Source  |  1995-11-13  |  876 b   |  39 lines

  1. import browser.Applet;
  2. import awt.Graphics;
  3.  
  4. class Bad extends Applet {
  5.  
  6.     static final int NUMLOOPS = 2000000;
  7.     int loop = 0;
  8.     boolean doneInitializing = false;
  9.     String message = null;
  10.     Thread loopThread = null;
  11.  
  12.     public void init() {
  13.     resize(500, 20);
  14.  
  15.     while (loop < NUMLOOPS) {
  16.         if ((++loop%50000)==0) {
  17.         message = "Bad: Initialization loop #"
  18.               + loop + " of " + NUMLOOPS;
  19.         showStatus(message);
  20.         repaint();
  21.         }
  22.     }
  23.     doneInitializing = true;
  24.     repaint();
  25.     }
  26.  
  27.     /* The paint() method can't be called until init() has exited. */
  28.     public void paint(Graphics g) {
  29.     g.clearRect(0, 0, width - 1, height - 1);
  30.     g.drawRect(0, 0, width - 1, height - 1);
  31.     if (message == null) 
  32.         g.drawString("Bad: ", 5, 15);
  33.     else if (!doneInitializing) 
  34.         g.drawString(message, 5, 15);
  35.     else 
  36.         g.drawString("Bad: Done initializing.", 5, 15);
  37.     }
  38. }
  39.