ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/conient/uk/org/iscream/cms/conient/datacomponents/StringDataComponent.java
Revision: 1.2
Committed: Mon Jan 22 12:32:14 2001 UTC (23 years, 3 months ago) by ajm
Branch: MAIN
Changes since 1.1: +57 -1 lines
Log Message:
All tidy now, fully javadoc comments

File Contents

# User Rev Content
1 ajm 1.2 //---PACKAGE DECLARATION---
2    
3     //---IMPORTS---
4 ajm 1.1 import javax.swing.JLabel;
5     import java.awt.GridLayout;
6    
7 ajm 1.2 /**
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: ajm4 $
14     * @version $Id: CPUDataComponent.java,v 1.1 2001/01/22 03:03:39 ajm4 Exp $
15     */
16 ajm 1.1 public class StringDataComponent extends DataComponent {
17 ajm 1.2
18     //---FINAL ATTRIBUTES---
19    
20     /**
21     * The current CVS revision of this class
22     */
23     public final String REVISION = "$Revision: 1.1 $";
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 ajm 1.1 public StringDataComponent(String name) {
36     _label = new JLabel(name + ": ");
37     _label.setHorizontalAlignment(JLabel.RIGHT);
38     setLayout(new GridLayout(1, 2));
39     add(_label);
40     add(_item);
41     }
42    
43 ajm 1.2 //---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 ajm 1.1 public void setValue(String value) throws DataFormatException {
58     try {
59     _item.setText(value);
60     } catch (Exception e) {
61     throw new DataFormatException("invalid data type for component");
62     }
63     }
64 ajm 1.2
65     //---ATTRIBUTES---
66    
67     /**
68     * The friendly label for this component
69     */
70     protected JLabel _label;
71 ajm 1.1
72 ajm 1.2 /**
73     * Just a normal label to display our value as a String
74     */
75 ajm 1.1 protected JLabel _item = new JLabel();
76 ajm 1.2
77     //---STATIC ATTRIBUTES---
78    
79 ajm 1.1 }