TextMenu

The TextMenu is a simple list of text entries with scroll capability. The menu items are displayed left-aligned and one below the other within the scope of the menus' area. Dimensions and position of the TextMenu are to be passed to the constructor. If the menu consists of more entries than can be shown at the same time, arrows at the upper and lower edge of the menu will indicate the enabled scroll functionality. The currently selected menu item will be marked by inverting this entry.

The following source code example scarcely differs from the one in section MenuBar, merely the MenuBar has been replaced by a TextMenu and some constructor parameters have been changed. Figure 3 shows a screenshot of the VoleTextMenuExample.

Figure 3: The VoleTextMenuExample

1    import jcontrol.ui.vole.Frame;
2    import jcontrol.ui.vole.menu.TextMenu;
3    
4    /**
5     * <p>This example demonstrates how to use the
6     * component TextMenu within the GUI framework
7     * JControl/Vole.</p>
8     *
9     * <p>(C) DOMOLOGIC Home Automation GmbH 2003-2005</p>
10     */
11    public class VoleTextMenuExample extends Frame {
12     
13      /**
14       * Create and show a TextMenu.
15       */
16      public VoleTextMenuExample() {
17    
18        // create the MenuBar
19        TextMenu menu = new TextMenu(0, 0, 50, 64);
20       
21        // add some menu items
22        menu.addMenuItem("Red");
23        menu.addMenuItem("Green");
24        menu.addMenuItem("White");
25        menu.addMenuItem("Blue");
26        menu.addMenuItem("Cyan");
27        menu.addMenuItem("Black");
28        menu.addMenuItem("Gray");
29        menu.addMenuItem("Orange");
30        menu.addMenuItem("Lime");
31        menu.addMenuItem("Yellow");
32        menu.addMenuItem("Brown");
33       
34        // add the menu bar to the Frame
35        this.setMenu(menu);
36       
37        // disable a menu item
38        menu.enableMenuItem("White", false);
39    
40        // show the frame   
41        setVisible(true);   
42      }
43    
44      /**
45       * Instantiate the VoleMenuBarExample
46       */
47      public static void main(String[] args) {
48        new VoleTextMenuExample();   
49      }
50    }
Listing 2: VoleTextMenuExample.java