/Users/lyon/j4p/src/graphics/ddd/RepaintThread.java

1    /* 
2     * Created by DocJava, Inc. 
3     * User: lyon 
4     * Date: Mar 30, 2003 
5     * Time: 9:53:34 AM 
6     */ 
7    package graphics.ddd; 
8     
9    import java.awt.*; 
10    
11    
12   class RepaintThread implements Runnable { 
13       private Thread rotationThread = null; 
14       private Component c = null; 
15       private long interval = 20; 
16    
17       public RepaintThread(Component c, long interval) { 
18           this.c = c; 
19           this.interval = interval; 
20       } 
21    
22       public void start() { 
23           if (rotationThread == null) { 
24               rotationThread = new Thread(this); 
25               rotationThread.start(); 
26           } 
27       } 
28    
29       public void stop() { 
30           if (rotationThread != null) { 
31               // now deprecated! 
32               // idx_Thread.stop(); 
33               rotationThread = null; 
34           } 
35       } 
36    
37       public void run() { 
38           while (true) { 
39               c.repaint(); 
40               try { 
41                   rotationThread.sleep(20); 
42               } catch (InterruptedException e) { 
43    
44               } 
45           } 
46       } 
47   } 
48    
49    
50    
51