Frame

The class jcontrol.ui.vole.Frame is responsible for keyboard queries, event handling and focus management. It also extends the class jcontrol.ui.vole.Container and therefore owns all of its features. Components and containers can be added to a frame. The following source code shows a simple application using JControl/Vole, displaying one Label-component and two Button-components.

Figure 2: Screenshot of the program VoleExampleBase

1    import jcontrol.ui.vole.Button;
2    import jcontrol.ui.vole.Frame;
3    import jcontrol.ui.vole.Label;
4    
5    /**
6     * <p>This example demonstrates how to implement JControl
7     * applications with a graphical user interface
8     * using the GUI framework JControl/Vole.</p>
9     *
10     * <p>(C) DOMOLOGIC Home Automation GmbH 2003-2005</p>
11     */
12    public class VoleExampleBase extends Frame {
13    
14      Button b1, b2;
15      Label l;
16    
17      /**
18       * Create and show a label and two buttons.
19       */
20      public VoleExampleBase() {
21        // create some components
22        l = new Label("Welcome to Vole!", 0, 5, 128, 10,
23                      Label.ALIGN_CENTER);
24        b1 = new Button("Button 1", 8,20,50,12);
25        b2 = new Button("Button 2", 62,20,50,12);
26    
27        // add the components to the frame
28        this.add(l);
29        this.add(b1);
30        this.add(b2);
31    
32        // make the frame visible
33        show();
34      }
35    
36      public static void main(String[] args) {
37        new VoleExampleBase();
38      }
39    }
Listing 1: VoleExampleBase.java

Figure 2 shows a screenshot of the example program shown above. You may download the examples' source code, add it to new JControl/IDE project, start the simulator and see the features of JControl/Vole action. The class Frame continously queries the keyboard. Using the pushbutton of a JControl device may toggle the focus between the two buttons. Since our example program doesn't install an ActionListener for the buttons, the program does not receive any ActionEvents and therefore it can't respond to a button being pressed. The event handling will be discussed in chapter 4 of this tutorial.