1 |
+ |
//---PACKAGE DECLARATION--- |
2 |
+ |
|
3 |
+ |
//---IMPORTS--- |
4 |
|
import javax.swing.JLabel; |
5 |
|
import java.awt.GridLayout; |
6 |
|
|
7 |
+ |
/** |
8 |
+ |
* This is the most basic of DataComponents. |
9 |
+ |
* |
10 |
+ |
* It simply displays the value as a String |
11 |
+ |
* in a JLabel. |
12 |
+ |
* |
13 |
+ |
* @author $Author$ |
14 |
+ |
* @version $Id$ |
15 |
+ |
*/ |
16 |
|
public class StringDataComponent extends DataComponent { |
17 |
+ |
|
18 |
+ |
//---FINAL ATTRIBUTES--- |
19 |
+ |
|
20 |
+ |
/** |
21 |
+ |
* The current CVS revision of this class |
22 |
+ |
*/ |
23 |
+ |
public final String REVISION = "$Revision$"; |
24 |
+ |
|
25 |
+ |
//---STATIC METHODS--- |
26 |
+ |
|
27 |
+ |
//---CONSTRUCTORS--- |
28 |
+ |
|
29 |
+ |
/** |
30 |
+ |
* Creates the component with a friendly name to be |
31 |
+ |
* used as label |
32 |
+ |
* |
33 |
+ |
* @param name the friendly name |
34 |
+ |
*/ |
35 |
|
public StringDataComponent(String name) { |
36 |
|
_label = new JLabel(name + ": "); |
37 |
|
_label.setHorizontalAlignment(JLabel.RIGHT); |
40 |
|
add(_item); |
41 |
|
} |
42 |
|
|
43 |
+ |
//---PUBLIC METHODS--- |
44 |
+ |
|
45 |
+ |
//---PRIVATE METHODS--- |
46 |
+ |
|
47 |
+ |
//---ACCESSOR/MUTATOR METHODS--- |
48 |
+ |
|
49 |
+ |
/** |
50 |
+ |
* This takes the String value of the parameter that this component |
51 |
+ |
* is monitoring direct from the packet, it then performs all |
52 |
+ |
* approriate conversions and displays the data. |
53 |
+ |
* |
54 |
+ |
* @param value the value for this data component |
55 |
+ |
* @throws DataFormatException if there was a problem converting the data for display |
56 |
+ |
*/ |
57 |
|
public void setValue(String value) throws DataFormatException { |
58 |
|
try { |
59 |
|
_item.setText(value); |
61 |
|
throw new DataFormatException("invalid data type for component"); |
62 |
|
} |
63 |
|
} |
64 |
< |
|
64 |
> |
|
65 |
> |
//---ATTRIBUTES--- |
66 |
> |
|
67 |
> |
/** |
68 |
> |
* The friendly label for this component |
69 |
> |
*/ |
70 |
|
protected JLabel _label; |
71 |
+ |
|
72 |
+ |
/** |
73 |
+ |
* Just a normal label to display our value as a String |
74 |
+ |
*/ |
75 |
|
protected JLabel _item = new JLabel(); |
76 |
+ |
|
77 |
+ |
//---STATIC ATTRIBUTES--- |
78 |
+ |
|
79 |
|
} |