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