/Users/lyon/j4p/src/net/rmi/rmiimage/CpuPanel.java

1    package net.rmi.rmiimage; 
2     
3    import java.awt.*; 
4    import java.awt.event.ItemEvent; 
5    import java.awt.event.ItemListener; 
6     
7    public class CpuPanel 
8        extends Panel implements 
9        BenchMarkListener, ItemListener { 
10     private CpuControlPanel cpucp 
11         = new CpuControlPanel(); 
12    
13     private Label speedLabel = 
14         new Label("0"); 
15    
16     private Choice cpuInfo 
17         = new Choice(); 
18    
19     private RectangleComponent 
20         onLightComponent = 
21         new RectangleComponent(false); 
22     private Checkbox cb = 
23         new Checkbox("on", true); 
24     private static 
25         int cpuNumber = 0; 
26     private float speed = 0; 
27    
28     CpuPanel(String cpuName, String IPAddress, String model) { 
29       setBackground(Color.white); 
30       cpuNumber++; 
31       setLayout(new GridLayout(0, 1)); 
32       cpucp.add(onLightComponent); 
33       cpucp.add(cb); 
34       cb.addItemListener(this); 
35       cpucp.add(speedLabel); 
36       cpuInfo.add("CPU:" + cpuNumber); 
37       cpuInfo.add(cpuName); 
38       cpuInfo.add(IPAddress); 
39       cpuInfo.add(model); 
40    
41       cpuInfo.setBackground(Color.white); 
42    
43       add(cpucp); 
44       add(cpuInfo); 
45     } 
46    
47     public void setSpeed(float _speed) { 
48       speed = _speed; 
49       speedLabel.setText 
50           ("     " + speed); 
51    
52     } 
53    
54     public float getSpeed() { 
55       return speed; 
56     } 
57    
58     public void setLightOn(boolean on) { 
59       onLightComponent.setState(on); 
60       cb.setState(on); 
61     } 
62    
63     boolean getstate() { 
64       return (cb.getState()); 
65     } 
66    
67     void checkboxChanged() { 
68       onLightComponent.setState(cb.getState()); 
69       //activate cpu or 
70       //deactivecpu 
71     } 
72    
73     public void itemStateChanged(ItemEvent e) { 
74       if (e.getSource() == cb) { 
75         checkboxChanged(); 
76         return; 
77       } 
78     } 
79   }