|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.microedition.midlet.MIDlet | +--Hello
This class implements a minimal J2ME MIDlet to show the various life cycle methods and provide an example for working out the details of compiling, packaging, and running midlets. Besides, a Hello World program must exist in all environments in order for the universe to continue smoothly on its course.
The main class of a midlet extends javax.microedition.midlet.MIDlet.
The screen displays are created and managed by subclasses of the abstract base class Displayable such as List. A Displayable object may have commands and listeners associated with it.
Commands are mapped to various buttons on the device. This mapping is controlled by the Application Management Software in the device. The action taken in response to a command is controlled by the midlet with one or more classes that implement the CommandListener interface.
Constructor Summary | |
Hello()
Create a new midlet based on the Hello class. |
Method Summary | |
void |
commandAction(javax.microedition.lcdui.Command c,
javax.microedition.lcdui.Displayable d)
Indicates that Command c has occurred on Displayable d. |
protected void |
destroyApp(boolean unconditional)
Signals the MIDlet to terminate and enter the Destroyed state. |
protected void |
pauseApp()
Signals the MIDlet to stop and enter the Paused state. |
protected void |
startApp()
Signals the MIDlet that it has entered the Active state. |
Methods inherited from class javax.microedition.midlet.MIDlet |
getAppProperty, notifyDestroyed, notifyPaused, resumeRequest |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Hello()
In this simple HelloWorld midlet, we just create a Displayable screen object of type List, add our text to it, add a Command and a CommandListener, and then return.
Method Detail |
protected void startApp()
startApp
in class javax.microedition.midlet.MIDlet
public void commandAction(javax.microedition.lcdui.Command c, javax.microedition.lcdui.Displayable d)
commandAction
in interface javax.microedition.lcdui.CommandListener
c
- a Command object identifying the command. This is either
one of the application's Commands that have been added to
the Displayable with Displayable.addCommand(Command) or is
the implicit SELECT_COMMAND of List.d
- the Displayable on which this event has occurredprotected void pauseApp()
pauseApp
in class javax.microedition.midlet.MIDlet
protected void destroyApp(boolean unconditional)
destroyApp
in class javax.microedition.midlet.MIDlet
unconditional
- If true when this method is called, the MIDlet
must cleanup and release all resources. If false the MIDlet may
throw MIDletStateChangeException to indicate it does not want to
be destroyed at this time. Our simple example does not implement
this optional behavior.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |