// Source code copyright by Developer's Daily, all rights reserved. // http://DevDaily.com import java.awt.*; import java.applet.*; //----------------------------------------------------------------------------// public class ThreadedCountdownField extends Thread { Label timeLabel; long timeRemaining; SiestaApplet thisApplet; //----------------(( constructor ))--------------// ThreadedCountdownField (SiestaApplet clientApplet) { thisApplet = clientApplet; timeLabel = thisApplet.timeRemainingLabel; timeRemaining = 5; } //----------------(( constructor ))--------------// ThreadedCountdownField (Label clientTimeLabel) { timeLabel = clientTimeLabel; timeRemaining = 5; } //--------------(( setTimeToSleep ))-------------// public void setTimeToSleep (long timeToSleep) { timeRemaining = timeToSleep; } //----------------(( run ))--------------// public void run () { while (timeRemaining > 0) { timeLabel.setForeground(Color.blue); timeLabel.setText(Long.toString(timeRemaining)); try {Thread.sleep(1000);} catch (InterruptedException e) {} timeRemaining--; } timeLabel.setForeground(Color.black); timeLabel.setText("0"); thisApplet.gong.play(); thisApplet.resetScreen(); } // end of run() }