1 |
ajm |
1.1 |
//---PACKAGE DECLARATION--- |
2 |
|
|
package uk.org.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 a pane using a card layout. |
10 |
|
|
* This class takes a container and a component to add |
11 |
|
|
* to the pane. 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: ajm4 $ |
16 |
|
|
* @version $Id: SwingSafeAddTab.java,v 1.2 2001/03/15 01:05:46 ajm4 Exp $ |
17 |
|
|
*/ |
18 |
|
|
public class SwingSafeAddCard 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.2 $"; |
26 |
|
|
|
27 |
|
|
//---STATIC METHODS--- |
28 |
|
|
|
29 |
|
|
//---CONSTRUCTORS--- |
30 |
|
|
|
31 |
|
|
/** |
32 |
|
|
* Constructs a new instance. |
33 |
|
|
* |
34 |
|
|
* @param container the container pane to add the component to |
35 |
|
|
* @param component the component to be added to the container |
36 |
|
|
* @param title the title for the card |
37 |
|
|
*/ |
38 |
|
|
public SwingSafeAddCard(Container container, JComponent component, String title) { |
39 |
|
|
_container = container; |
40 |
|
|
_component = component; |
41 |
|
|
_title = title; |
42 |
|
|
} |
43 |
|
|
|
44 |
|
|
//---PUBLIC METHODS--- |
45 |
|
|
|
46 |
|
|
/** |
47 |
|
|
* Executed by the Swing Event Dispatch thread |
48 |
|
|
* to update the display. |
49 |
|
|
*/ |
50 |
|
|
public void run() { |
51 |
|
|
_container.add( _component, _title); |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
//---PRIVATE METHODS--- |
55 |
|
|
|
56 |
|
|
//---ACCESSOR/MUTATOR METHODS--- |
57 |
|
|
|
58 |
|
|
//---ATTRIBUTES--- |
59 |
|
|
|
60 |
|
|
/** |
61 |
|
|
* The component to add |
62 |
|
|
*/ |
63 |
|
|
private JComponent _component; |
64 |
|
|
|
65 |
|
|
/** |
66 |
|
|
* The container to add the component to |
67 |
|
|
*/ |
68 |
|
|
private Container _container; |
69 |
|
|
|
70 |
|
|
/** |
71 |
|
|
* The title of the tab |
72 |
|
|
*/ |
73 |
|
|
private String _title; |
74 |
|
|
|
75 |
|
|
//---STATIC ATTRIBUTES--- |
76 |
|
|
|
77 |
|
|
} |