Java Reference
In-Depth Information
Figure 3-8.
The MIDlet life cycle
As is generally the case, WeatherWidget doesn't do any object creation at construc-
tion time; instead, object creation is deferred until the application starts. The application
manager-invoked
startApp
delegates the creation of items for the GUI to initialize and
sets the display's current form to the
wxForm
field. The application does nothing on appli-
cation pause or destruction, instead relying on the Java garbage collector upon
destruction to reclaim the memory used by the application forms.
The MIDP environment provides a generalized notion of events; instead of
handling events such as specific key presses, the runtime provides abstractions such
as
OK
,
back
, and
help
. This abstraction permits the MIDP to run on a wide variety of
devices, from touchscreen-only devices, to traditional phones with a four-way naviga-
tion pad and two soft keys, to speech-driven user interfaces. The system sends these
commands to the MIDlet using the
commandAction
method, which simply switches
on the incoming command to determine what screen to show or whether to exit
completely (on an
exitCommand
).