1 |
/* |
2 |
* i-scream central monitoring system |
3 |
* Copyright (C) 2000-2002 i-scream |
4 |
* |
5 |
* This program is free software; you can redistribute it and/or |
6 |
* modify it under the terms of the GNU General Public License |
7 |
* as published by the Free Software Foundation; either version 2 |
8 |
* of the License, or (at your option) any later version. |
9 |
* |
10 |
* This program is distributed in the hope that it will be useful, |
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
* GNU General Public License for more details. |
14 |
* |
15 |
* You should have received a copy of the GNU General Public License |
16 |
* along with this program; if not, write to the Free Software |
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 |
*/ |
19 |
|
20 |
//---PACKAGE DECLARATION--- |
21 |
package uk.org.iscream.cms.conient; |
22 |
|
23 |
//---IMPORTS--- |
24 |
import javax.swing.JComponent; |
25 |
import java.awt.Container; |
26 |
|
27 |
/** |
28 |
* Allows components to be safely added to containers |
29 |
* This class takes a container and a component to add |
30 |
* to the container. It then should be added to the |
31 |
* Swing Event Dispatching Thread in order that the |
32 |
* add can carry out. |
33 |
* |
34 |
* @author $Author: tdb $ |
35 |
* @version $Id: SwingSafeAdd.java,v 1.3 2001/05/29 17:41:32 tdb Exp $ |
36 |
*/ |
37 |
public class SwingSafeAdd implements Runnable { |
38 |
|
39 |
//---FINAL ATTRIBUTES--- |
40 |
|
41 |
/** |
42 |
* The current CVS revision of this class |
43 |
*/ |
44 |
public static final String REVISION = "$Revision: 1.3 $"; |
45 |
|
46 |
//---STATIC METHODS--- |
47 |
|
48 |
//---CONSTRUCTORS--- |
49 |
|
50 |
/** |
51 |
* Constructs a new instance. |
52 |
* |
53 |
* @param container the container to add the component to |
54 |
* @param component the component to be added to the container |
55 |
*/ |
56 |
public SwingSafeAdd(Container container, JComponent component) { |
57 |
_container = container; |
58 |
_component = component; |
59 |
} |
60 |
|
61 |
//---PUBLIC METHODS--- |
62 |
|
63 |
/** |
64 |
* Executed by the Swing Event Dispatch thread |
65 |
* to update the display. |
66 |
*/ |
67 |
public void run() { |
68 |
_container.add(_component); |
69 |
} |
70 |
|
71 |
//---PRIVATE METHODS--- |
72 |
|
73 |
//---ACCESSOR/MUTATOR METHODS--- |
74 |
|
75 |
//---ATTRIBUTES--- |
76 |
|
77 |
/** |
78 |
* The component to add |
79 |
*/ |
80 |
private JComponent _component; |
81 |
|
82 |
/** |
83 |
* The container to add the component to |
84 |
*/ |
85 |
private Container _container; |
86 |
|
87 |
//---STATIC ATTRIBUTES--- |
88 |
|
89 |
} |