Java Reference
In-Depth Information
Figure 3.2 shows an overview of the MIDP GUI classes and their inheritance structure.
Figure 3.2. The MIDP GUI classes.
The following sections first describe the high-level API and then the low-level API. A more complex
sample application that uses both levels of the lcdui package together is shown in Chapter 9 ,
"Advanced Application: Blood Sugar Log."
High-Level API
Now that you know the basics of the MIDlet's life cycle and general display model, we can start to look
deeper into the lcdui package. We will start with another subclass of Screen : Alert . Then we will
discuss some simple Item s like StringItem and ImageItem . We will explain the use of more
advanced Item s such as TextField and ChoiceGroup by creating a simple TeleTransfer
example application. As we introduce new MIDP high-level UI capabilities like other Screen
subclasses, we will extend the TeleTransfer sample step by step.
Alerts
You already know the Form class from the first example. The simplest subclass of Screen is Alert .
Alert provides a mechanism to show a dialog for a limited period of time. It consists of a label, text,
and an optional Image . Furthermore, it is possible to set a period of time the Alert will be displayed
before another Screen is shown. Alternatively, an Alert can be shown until the user confirms it. If
the Alert does not fit on the screen and scrolling is necessary to view it entire contents, the time limit
is disabled automatically.
The following code snippet creates an Alert with the title "HelloAlert" and displays it until it is
confirmed by the user:
Alert alert = new Alert ("HelloAlert");
alert.setTimeout (Alert.FOREVER);
display.setCurrent (alert);
 
 
 
Search WWH ::




Custom Search