1 |
//---PACKAGE DECLARATION--- |
2 |
package uk.ac.ukc.iscream.conient; |
3 |
|
4 |
//---IMPORTS--- |
5 |
import javax.swing.JComponent; |
6 |
import java.awt.Container; |
7 |
|
8 |
/** |
9 |
* Allows components to be safely added to containers |
10 |
* This class takes a container and a component to add |
11 |
* to the container. It then should be added to the |
12 |
* Swing Event Dispatching Thread in order that the |
13 |
* add can carry out. |
14 |
* |
15 |
* @author $Author: tdb1 $ |
16 |
* @version $Id: TemplateClass.java,v 1.10 2001/01/18 23:14:39 tdb1 Exp $ |
17 |
*/ |
18 |
public class SwingSafeAdd implements Runnable { |
19 |
|
20 |
//---FINAL ATTRIBUTES--- |
21 |
|
22 |
/** |
23 |
* The current CVS revision of this class |
24 |
*/ |
25 |
public static final String REVISION = "$Revision: 1.10 $"; |
26 |
|
27 |
//---STATIC METHODS--- |
28 |
|
29 |
//---CONSTRUCTORS--- |
30 |
|
31 |
/** |
32 |
* Constructs a new instance. |
33 |
* |
34 |
* @param container the container to add the component to |
35 |
* @param component the component to be added to the container |
36 |
*/ |
37 |
public SwingSafeAdd(Container container, JComponent component) { |
38 |
_container = container; |
39 |
_component = component; |
40 |
} |
41 |
|
42 |
//---PUBLIC METHODS--- |
43 |
|
44 |
/** |
45 |
* Executed by the Swing Event Dispatch thread |
46 |
* to update the display. |
47 |
*/ |
48 |
public void run() { |
49 |
_container.add(_component); |
50 |
} |
51 |
|
52 |
//---PRIVATE METHODS--- |
53 |
|
54 |
//---ACCESSOR/MUTATOR METHODS--- |
55 |
|
56 |
//---ATTRIBUTES--- |
57 |
|
58 |
/** |
59 |
* The component to add |
60 |
*/ |
61 |
private JComponent _component; |
62 |
|
63 |
/** |
64 |
* The container to add the component to |
65 |
*/ |
66 |
private Container _container; |
67 |
|
68 |
//---STATIC ATTRIBUTES--- |
69 |
|
70 |
} |