home *** CD-ROM | disk | FTP | other *** search
/ Java by Example / jbecd.bin / JBE-CD / NTUsers / JBECODE.ZIP / JavaByExample / chap32 / ColorThread.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-03-22  |  887 b   |  36 lines

  1. import java.awt.Color;
  2.  
  3. public class ColorThread extends Thread {
  4.    ThreadApplet5 applet;
  5.    int count;
  6.  
  7.    ColorThread(ThreadApplet5 var1) {
  8.       this.applet = var1;
  9.    }
  10.  
  11.    public void run() {
  12.       while(true) {
  13.          if (this.applet.color1 == Color.red) {
  14.             this.applet.color1 = Color.blue;
  15.             this.applet.color2 = Color.red;
  16.             this.applet.color3 = Color.green;
  17.          } else if (this.applet.color1 == Color.blue) {
  18.             this.applet.color1 = Color.green;
  19.             this.applet.color2 = Color.blue;
  20.             this.applet.color3 = Color.red;
  21.          } else {
  22.             this.applet.color1 = Color.red;
  23.             this.applet.color2 = Color.green;
  24.             this.applet.color3 = Color.blue;
  25.          }
  26.  
  27.          this.applet.repaint();
  28.  
  29.          try {
  30.             Thread.sleep(100L);
  31.          } catch (InterruptedException var1) {
  32.          }
  33.       }
  34.    }
  35. }
  36.