KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > notification > whiteboard > GhostPainter


1 package demo.notification.whiteboard;
2
3
4
5 /**
6
7  * GhostPainter.java
8
9  *
10
11  *
12
13  * Created: Wed Feb 9 18:45:20 2000
14
15  *
16
17  * @author Alphonse Bendt
18
19  * @version
20
21  */

22
23
24
25 // Wenn der GhostPainter einmal gestartet ist,
26

27 // schla"ft er eine gewisse Zeit
28

29 // und malt dann unvermittelt im u"bergebenen AWTWin
30

31 // Linien ...
32

33
34
35 public class GhostPainter extends Thread JavaDoc {
36
37     
38
39     int x,y;
40
41     long sleep = 5000;
42
43     IWorkgroupFrame w;
44
45     boolean active_ = true;
46
47
48
49     public GhostPainter(IWorkgroupFrame w,int x, int y) {
50
51     this.x = x;
52
53     this.y = y;
54
55     this.w = w;
56
57     }
58
59     
60
61     public void shutdown() {
62
63     active_ = false;
64
65     interrupt();
66
67     }
68
69
70
71     public void run() {
72
73     while (active_) {
74
75         try {
76
77         sleep ((long) (sleep * Math.random()) );
78
79         } catch (InterruptedException JavaDoc ie) {
80
81         if (!active_) {
82
83             return;
84
85         }
86
87         }
88
89         
90
91         int x0 = (int) (Math.random() * x);
92
93         int x1 = (int) (Math.random() * x);
94
95         int y1 = (int) (Math.random() * y);
96
97         int y0 = (int) (Math.random() * y);
98
99     }
100
101     }
102
103 } // GhostPainter
104

105
106
107
Popular Tags