Yurttas/PL/OOL/Java/F/07/02/A/A01.java
Jump to navigation
Jump to search
1/**
2 * Copyright(C) 1998
3 * All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4 *
5 * Permission to use, copy, modify, and distribute this
6 * software and its documentation for EDUCATIONAL purposes
7 * and without fee is hereby granted provided that this
8 * copyright notice appears in all copies.
9 *
10 * @date : January 1, 1998.
11 * @author : Salih Yurttas.
12 */
13
14
15import java.applet.*;
16import java.awt.*;
17
18public class A01 extends Applet
19 implements Runnable {
20
21 Thread t;
22 int count;
23 boolean suspended;
24
25 public void init() {
26 count=0;
27 suspended=false;
28 t=new Thread(this);
29 t.start();
30 }
31
32 public boolean mouseDown(Event e,
33 int x,
34 int y) {
35 if(suspended)
36 t.resume();
37 else
38 t.suspend();
39 suspended = !suspended;
40 return true;
41 }
42
43 public void run() {
44 while(true) {
45 count++;
46 repaint();
47 try {
48 t.sleep(10);
49 }
50 catch(InterruptedException iE) {}
51 }
52 }
53
54 public void paint(Graphics g) {
55 g.drawString(Integer.toString(count),10,10);
56 }
57
58 public void stop() {
59 t.stop();
60 }
61
62}