Method | Description |
DigitalMeter(int x, int y, int digits, int decimals) | Creates a new DigitalMeter at the given coordinates. Parameter digits defines total number of displayed digits, decimals specifies the number of decimals included in digits . Example: digits=4 and decimals=3 will display values in form of x,xxx . The components' dimensions result from the used Font (method setFont(Resource font) ) and the specified number of digits. |
SevenSegmentMeter(int x, int y, int width, int height, int digits, int decimals) | Creates a new SevenSegmentMeter at the given coordinates. width and height specify the components' size and therefore the size of the displayed digits. Parameter digits defines total number of displayed digits, decimals specifies the number of decimals included in digits . Example: digits=4 and decimals=3 will display values in form of x,xxx . |
setValue(int value) | Passes a new value to the SevenSegmentMeter and DigitalMeter respectively, which thereupon will be updated. |
1 | import java.io.IOException; |
2 | |
3 | import jcontrol.io.Resource; |
4 | import jcontrol.lang.Math; |
5 | import jcontrol.lang.ThreadExt; |
6 | import jcontrol.ui.vole.Border; |
7 | import jcontrol.ui.vole.Frame; |
8 | import jcontrol.ui.vole.meter.DigitalMeter; |
9 | import jcontrol.ui.vole.meter.SevenSegmentMeter; |
10 | |
11 | /** |
12 | * <p>This example demonstrates how to use the |
13 | * component DigitalMeter within the GUI framework |
14 | * JControl/Vole. |
15 | * This example needs the font resource |
16 | * "arial24.jcfd".</p> |
17 | * |
18 | * <p>(C) DOMOLOGIC Home Automation GmbH 2003-2005</p> |
19 | */ |
20 | public class VoleDigitalMeterExample extends Frame { |
21 | |
22 | public VoleDigitalMeterExample() { |
23 | // create the DigitalMeter |
24 | DigitalMeter dm = new DigitalMeter(13, 20, 3, 1); |
25 | |
26 | // set the Font of the DigitalMeter |
27 | try { |
28 | dm.setFont(new Resource("arial24.jcfd")); |
29 | } catch (IOException e) {} |
30 | |
31 | // add the DigitalMeter to the Frame |
32 | this.add(dm); |
33 | |
34 | // create the LCDMeter |
35 | SevenSegmentMeter sm = new SevenSegmentMeter(70, 10, 50, |
36 | 50, 2, 0); |
37 | this.add(sm); |
38 | |
39 | // make some pretty borders |
40 | this.add(new Border("DigitalMeter", 0, 0, 63, 60)); |
41 | this.add(new Border("SevenSegment", 64, 0, 63, 60)); |
42 | |
43 | // make the frame visible |
44 | show(); |
45 | |
46 | |
47 | // produce some random values |
48 | for (;;) { |
49 | dm.setValue(Math.rnd(2000)-1000); |
50 | sm.setValue(Math.rnd(150)-50); |
51 | try{ ThreadExt.sleep(1000); }catch(InterruptedException e){} |
52 | } |
53 | } |
54 | |
55 | // start the demonstration |
56 | public static void main(String[] args) { |
57 | new VoleDigitalMeterExample(); |
58 | } |
59 | } |