home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java by Example
/
jbecd.bin
/
JBE-CD
/
NTUsers
/
JBECODE.ZIP
/
JavaByExample
/
chap31
/
ColorThread.java
< prev
next >
Wrap
Text File
|
1996-03-21
|
1KB
|
49 lines
import java.awt.Color;
public class ColorThread extends Thread
{
ThreadApplet5 applet;
int count;
ColorThread(ThreadApplet5 applet)
{
this.applet = applet;
}
public void run()
{
while (true)
{
if (applet.color1 == Color.red)
{
applet.color1 = Color.blue;
applet.color2 = Color.red;
applet.color3 = Color.green;
}
else if (applet.color1 == Color.blue)
{
applet.color1 = Color.green;
applet.color2 = Color.blue;
applet.color3 = Color.red;
}
else
{
applet.color1 = Color.red;
applet.color2 = Color.green;
applet.color3 = Color.blue;
}
applet.repaint();
try
{
sleep(100);
}
catch (InterruptedException e)
{
}
}
}
}