Source code: org/incenter/ngbclient/netBug.java
1
2 package org.incenter.ngbclient;
3
4 import org.incenter.ngbclient.*;
5 import java.awt.*;
6 import java.net.*;
7 import java.io.*;
8 import java.lang.*;
9
10 public class netBug extends Canvas
11 implements Runnable
12 {
13 busyObject busyObj;
14 Thread thread;
15 boolean painting, busy;
16 String statusMsg = "";
17 int sz = 25;
18 Color wc = Color.red, rc = Color.green;
19
20 public netBug(busyObject bo) {
21 busyObj = bo;
22 setSize(25,25);
23 setBackground(Color.black);
24 thread = new Thread(this);
25 thread.start();
26 }
27
28 public void stop() { thread.stop();}
29
30 public void run() {
31 try {
32 while(true) {
33 busy = busyObj.isBusy();
34 repaint();
35
36 thread.yield();
37 }
38 } catch(Exception e) {
39 statusMsg = "ERROR:" + e;
40 }
41 }
42
43 public void paint(Graphics g) {
44 try {
45 if(!busy) {
46 g.setColor(Color.black);
47 g.fillRect(0,0,sz,sz);
48 }
49 if(!busy) return;
50
51 painting = true;
52 for(int i=sz;i>0;i--) {
53 if(busy) {
54 g.setColor(wc);
55 g.drawRect(0,0,i,i);
56 }
57 thread.sleep(1000);
58 }
59 painting = false;
60 } catch(Exception e) {
61 painting = false;
62 statusMsg = "ERROR:" + e;
63 }
64 }
65
66 }