Java Reference
In-Depth Information
input.setFlags(VISIBLE | LINEFEED | FOCUSABLE);
content.add(input);
}
After creation and placement of UI components in the createForm()
method, we create a root component, an instance of the Shell class. It
holds all other components and can be thought of as being like a Screen
(from MIDP) that is displayed to the user. The framework manipulates
those shells, using a stack, to determine which one should be displayed
at any given time. Returning this shell object in openWidget() causes
it to be displayed as the first 'window' of our application.
Besides having softkey commands, our Form view has also a Menu,
displayed when the left softkey is pressed (see Figure A.8). To create this
menu we use the code below:
void startWidget() {
setMinimizedView(createMinimizedView("viewMini", getStyle("default")));
if(menu == null) {
menu = new Menu();
menu.add(CMD_SEARCH, "Search");
menu.add(CMD_SAVE,"Save search");
menu.add(CMD_LOAD,"Load search");
}
}
Figure A.8 Form view with a Menu displayed
You only need to create a Menu object and add items to it; they are
composed of an ID (defined as a constant at the beginning of the class)
and a label which is displayed.
The menu can be displayed in two ways: using the getMenu()
callback, which returns an instance of a Menu class like the one
Search WWH ::




Custom Search