home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Component;
- import java.awt.Font;
- import java.awt.Graphics;
-
- public class ThreadApplet extends Applet implements Runnable {
- Thread thread;
- int count;
- String displayStr;
- Font font;
-
- public void start() {
- this.font = new Font("TimesRoman", 0, 72);
- ((Component)this).setFont(this.font);
- this.count = 0;
- this.displayStr = "";
- this.thread = new Thread(this);
- this.thread.start();
- }
-
- public void stop() {
- this.thread.stop();
- }
-
- public void run() {
- while(this.count < 1000) {
- ++this.count;
- this.displayStr = String.valueOf(this.count);
- ((Component)this).repaint();
-
- try {
- Thread.sleep(100L);
- } catch (InterruptedException var1) {
- }
- }
-
- }
-
- public void paint(Graphics var1) {
- var1.drawString(this.displayStr, 50, 130);
- }
- }
-