Gauge Bean Samples
Connecting Two Gauges Together
One way to quickly see the Gauge Beans is to try them out using IBM VisualAge for Java.
In this sample, you update the value of a Bar Indicator gauge using an editable Needle
gauge.
- Open IBM VisualAge for Java and import s103_gauges.jar into a
palette of your choice. (See the VisualAge for Java documentation if you need help).
- Create a new JApplet by choosing Selected -> Add -> Applet...
Ensure that the super class of the applet is com.sun.java.JApplet.
- Add a Needle Gauge bean to the workspace:
- Add a Bar Indicator Gauge Bean to the workspace:
- Double-click the needle gauge to bring up its Properties window:
- Set the editable property to True, which lets you click and drag the needle to update
the gauges' values.
- Now you can connect the Bar Indicator and Needle Gauge beans together. Right-click on
the Needle Gauge bean and select Connect -> Connectable Features to bring up the
connection dialog:
- Choose the model property from the property list. If the model property does not
appear in the list, ensure that Show expert features is checked.
- Move the mouse over the Bar Indicator bean and click it to create the connection. This
brings up a menu to complete the connection. Select Connectable Features to
bring up the connection dialog and choose the model property from the properties
list as before.
- To see the connection in action select Bean -> Run -> In AppletViewer.
Manipulate the Needle gauge, and the value displayed by the Bar Indicator will change.
Using Accumulation to Set the Gauge Value
In this sample, you set the gauge value by accumulating events. You connect a JTextPane
to an LEDCounter Gauge.
- Open IBM VisualAge for Java and load gauges.jar and gaugetest.jar into a palette of your choice. (See the IBM
VisualAge for Java documentation if you need help doing this). If VisualAge for Java is
already open, select Edit - Select All, then Edit - Cut
to clear the workspace.
- Add an instance of the JTextPane bean and the LEDCounter bean, from the Swing and Gauges
palettes respectively, onto the workspace:

- Double-click on the LED Counter bean to bring up its Properties window. Set the accumulatorInterval
property to 1000 and the accumulatorEnabled property to True.
- Right-click on the JTextPane, and select Connect -> keyTyped:

- Move the mouse over the LED Counter bean and click to create the connection. This brings
up a menu to allow you to complete the connection. Select Connectable Features to
bring up the connection dialog and choose the accumulate( ) method from the method
list.
- Select Bean - Run - In AppletViewer, and then type into the text area
as fast as you can. The LED Counter bean updates to show you how many keys per second you
are typing.
