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/CPUDataComponent.java
(Generate patch)

Comparing projects/cms/source/conient/uk/org/iscream/cms/conient/datacomponents/CPUDataComponent.java (file contents):
Revision 1.4 by ajm, Wed Jan 24 03:11:14 2001 UTC vs.
Revision 1.6 by ajm, Mon Jan 29 13:58:45 2001 UTC

# Line 5 | Line 5 | package uk.ac.ukc.iscream.conient.datacomponents;
5   import javax.swing.JLabel;
6   import java.awt.GridLayout;
7   import javax.swing.JProgressBar;
8 + import javax.swing.SwingUtilities;
9  
10   /**
11   * This is DataComponent specifically for
# Line 15 | Line 16 | import javax.swing.JProgressBar;
16   * @author  $Author$
17   * @version $Id$
18   */
19 < public class CPUDataComponent extends VisibleDataComponent implements DataComponent {
19 > public class CPUDataComponent extends VisibleDataComponent {
20  
21   //---FINAL ATTRIBUTES---
22  
# Line 41 | Line 42 | public class CPUDataComponent extends VisibleDataCompo
42          _label = new JLabel(_name + ": ");
43          _label.setHorizontalAlignment(JLabel.RIGHT);
44          setLayout(new GridLayout(1, 2));
45 +        _item.setString("-uninitialised-");
46          add(_label);
47          add(_item);
48      }
# Line 48 | Line 50 | public class CPUDataComponent extends VisibleDataCompo
50   //---PUBLIC METHODS---
51  
52      /**
53 +     * This run method updates any Swing components
54 +     * The setValue() method adds this component
55 +     * to the Swing Event Dispatching Queue to
56 +     * run this method.
57 +     */
58 +    public void run() {
59 +        _item.setString(_cache + "%");
60 +        _item.setValue(new Double(_cache).intValue());
61 +    }
62 +
63 +    /**
64       * Overrides the {@link java.lang.Object#toString() Object.toString()}
65       * method to provide clean logging (every class should have this).
66       *
# Line 64 | Line 77 | public class CPUDataComponent extends VisibleDataCompo
77      /**
78       * This takes the String value of the parameter that this component
79       * is monitoring direct from the packet, it then performs all
80 <     * approriate conversions and displays the data.
80 >     * approriate conversions and adds this class to the Swing Event
81 >     * Dispatching queue.
82       *
83       * @param value the value for this data component
84       * @throws DataFormatException if there was a problem converting the data for display
# Line 73 | Line 87 | public class CPUDataComponent extends VisibleDataCompo
87          try {
88              if(!_cache.equals(value)) {
89                  _cache = value;
90 <                _item.setString(value + "%");
77 <                _item.setValue(new Double(value).intValue());
90 >                SwingUtilities.invokeLater(this);
91              }
92          } catch (Exception e) {
93              throw new DataFormatException(value + " is an invalid data type for " + toString());
# Line 125 | Line 138 | public class CPUDataComponent extends VisibleDataCompo
138  
139   //---STATIC ATTRIBUTES---
140  
141 < }
141 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines