Java Reference
In-Depth Information
mainForm = new Form ("HelloMidp");
}
A Form is a specialized Displayable class. The Form has a title that is given in the constructor.
You do not add content to the form yet, so only the title will be displayed. (A detailed description of
the Form class is contained in the next section.)
When your MIDlet is started the first time, or when the MIDlet resumes from a paused state, the
startApp() method is called by the program manager. Here, you set the display to your form, thus
requesting the form to be displayed:
public void startApp() {
display = Displayable.getDisplay (this);
display.setCurrent (mainForm);
}
When the application is paused, you do nothing because you do not have any allocated resources to free.
However, you need to provide an empty implementation because implementation of pauseApp() is
mandatory:
public void pauseApp() {
}
Like pauseApp() , implementation of destroyApp() is mandatory. Again, you don't need to do
anything here for this simple application:
public void destroyApp(boolean unconditional) {
}
}
Note
The HelloMidp Midlet does not provide a command to exit the MIDlet, assuming that the device
provides a general method of terminating MIDlets. For real MIDP applications, we recommend that
you add a command to terminate the MIDlet because the MIDP specification does not explicitly
support this assumption. More information about commands can be found in the section " Using
Commands for User Interaction . "
MIDP User Interface APIs
The MIDP user interface API is divided into a high- and low-level API. The high-level API provides
input elements such as text fields, choices, and gauges. In contrast to the Abstract Window Toolkit
(AWT), the high-level components cannot be positioned or nested freely. There are only two fixed
levels: Screen s and Item s. The Item s can be placed in a Form , which is a specialized Screen .
The high-level Screen s and the low-level class Canvas have the common base class
Displayable . All subclasses of Displayable fill the whole screen of the device. Subclasses of
Displayable can be shown on the device using the setCurrent() method of the Display
object. The display hardware of a MIDlet can be accessed by calling the static method
getDisplay() , where the MIDlet itself is given as parameter. In the HelloMidp example, this
step is performed in the following two lines:
Display display = Display.getDisplay (this);
...
display.setCurrent (mainForm);
Search WWH ::




Custom Search