Slide 3.12: Line-by-line anatomy of HelloMIDlet.java (cont.)
  Slide 3.14: User interface
  Home


Line-by-line Anatomy of HelloMIDlet.java (Cont.)


display.setCurrent(tbxMain);
When a MIDlet application is first started, there is no current Displayable object. It is the responsibility of the application to ensure that a Displayable is visible and can interact with the user at all times. Thus, the application should always call setCurrent( ) as part of its initialization. The method public void javax.microedition.lcdui.Display.setCurrent (Displayable nextDisplayable) requests that a different Displayable object be made visible on the display.

public void pauseApp( ) { }
public void destroyApp(boolean unconditional) { }

These two methods usually have empty bodies.

public void commandAction(Command c, Displayable s) {
This method implements the method public void javax.microedition.lcdui.CommandListener.commandAction(Command c, Displayable d), which indicates that a command event has occurred on Displayable d.

if (c == cmdExit) {
It checks to see if the Exit command was selected.

destroyApp(false);
A MIDlet can destroy itself by calling the method destroyApp( ), which is empty in this case.

notifyDestroyed( );
The method public final void javax.microedition.midlet.MIDlet.notifyDestroyed( ) notifies the application management software that it has entered into the Destroyed state. The JAM software will not call the MIDlet's destroyApp method, and all resources held by the MIDlet will be considered eligible for reclamation. The MIDlet must have performed the same operations (clean up, releasing of resources etc.) it would have if the MIDlet.destroyApp( ) had been called.