Java Reference
In-Depth Information
If you forget what you put in a form, you can find out the number of items and retrieve
them with the following methods:
public int size()
public Item get(int index)
Understanding Form Layout
MIDs can have very different screen size and shapes. Forms have support for very specific
layout. There's an exhaustive description of the layout algorithm in the documentation for
javax.microedition.lcdui.Form
, in the section titled “Layout.” Stated briefly,
Form
attempts to
lay out items left-to-right in rows, stacking rows top-to-bottom, just like English text on a page.
The
Item
class includes plumbing that allows some control over the layout of individual items.
The Item Pantry
The MIDP specification includes a handy toolbox of items that can be used to build forms.
We'll cover each of them briefly in the following sections and show how some of them look in
Sun's MIDP reference implementation.
The Item Class
All of the items that can be added to forms descend from the class
javax.microedition.lcdui.Item
.
This class has a
getLabel()
and
setLabel()
method. All
Item
s have a string label, although it
may or may not be shown by the specific subclass.
Item
s can also have commands, just like
Displayable
s. When an
Item
is selected in a form,
the
Item
's commands are shown along with the commands in the form. Figure 6-3 shows a
form with four string items, cunningly named “one,” “two,” “three,” and “four.” The form itself
has one command, “Exit.” None of the string items has commands, except for “three,” which
has one command named “Details.”
Figure 6-3.
Item “three” has a command.
Search WWH ::
Custom Search