|
8.7.7.2.8 Led
Here is a bean component that changes its color depending on the threshold value crossed. So, depending on the seriousness, whether the value is at critical level, danger level or at warning level, the color of the Led changes.
You can set the background and the foreground colors. You can set the different Threshold values for the different Threshold colors. You can also decide the number of different states.
Following are some of the main events that are invoked by the Led component - component events, focus events, key events, mouse events, mouse motion events, property change and vetoable Change.
These are useful if you want to write event Listeners or use the Interaction Wizard to get another bean to behave in a particular way once a certain event occurs.
Following are some of the main properties associated with the Led component.
|
Property
|
Description
|
|
NoOfStates |
Sets the number of Threshold states |
|
Threshold Color1-7 |
Sets the different colors for the various threshold values. |
|
Threshold Label1-7 |
Sets the label names for the various threshold values. |
|
Threshold Value1-7 |
Sets the various threshold values for the component |
|
Show Value |
Sets whether to show the value or not. |
The main method is the setResult method which sets the Led display to be the color pertaining to a polled value.
How to Use the Led Bean
The Led bean can be used alongwith other beans like the JTextField(to display the value that is given in the text-field). The following code snippet explains how to instantiate and use some of the methods corresponding to the Led.
com.adventnet.beans.Led led1 = new com.adventnet.beans.Led();
led1.setBgColor(Color.black);
led1.setNumberOfStates(3);
led1.setThresholdColor1(Color.red);
led1.setThresholdColor2(Color.blue);
led1.setThresholdColor3(Color.green);
led1.setThresholdValue1(10);
led1.setThresholdValue(20);
led1.setThresholdValue(30); led1.setResult(20);
The first line instantiates the Led. The second line sets the background color to be black. The third line sets the number of states to be three. The fourth , fifth and sixth lines set the threshold colors to be red, blue and green respectively. The seventh , eighth and ninth lines set the threshold values to be 10, 20 and 30 respectively. The last line sets the value displayed by Led to be 20. So , the color displayed should be blue.
Now, using the Interaction Wizard, this can be connected to beans like the JTextField bean or the beans in the Snmp jar or other beans.
|