m3g04
Class Main

java.lang.Object
  extended by javax.microedition.midlet.MIDlet
      extended by m3g04.Main
All Implemented Interfaces:
javax.microedition.lcdui.CommandListener

public class Main
extends javax.microedition.midlet.MIDlet
implements javax.microedition.lcdui.CommandListener

Application that runs the samples available in this chapter. The user can pick a sample from a list to start it and return to the selection screen when finished.

Author:
Claus Hoefele

Field Summary
private  javax.microedition.lcdui.Command backCommand
          Back command.
private  Sample currentSample
          Currently displayed sample.
private  javax.microedition.lcdui.Command exitCommand
          Exit command.
private static java.lang.String[][] SAMPLES
          List of samples.
private  javax.microedition.lcdui.List selectionScreen
          Screen for selecting samples.
 
Constructor Summary
Main()
          Constructor.
 
Method Summary
 void commandAction(javax.microedition.lcdui.Command command, javax.microedition.lcdui.Displayable displayable)
          Receives command actions from the selection screen as well as the samples.
 void destroyApp(boolean unconditional)
          Enters the destroyed state.
 void pauseApp()
          Enters the paused state.
 void startApp()
          Enters the active state.
private  void switchSample(Sample newSample)
          Destroys the current sample if it exists and displays a new one.
 
Methods inherited from class javax.microedition.midlet.MIDlet
checkPermission, getAppProperty, notifyDestroyed, notifyPaused, platformRequest, resumeRequest
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SAMPLES

private static final java.lang.String[][] SAMPLES
List of samples. They will be displayed in the same order as defined here. The first string is the class name, the second the display name. A sample must implement the interface Sample and derive from Displayable.


selectionScreen

private javax.microedition.lcdui.List selectionScreen
Screen for selecting samples.


currentSample

private Sample currentSample
Currently displayed sample.


exitCommand

private javax.microedition.lcdui.Command exitCommand
Exit command.


backCommand

private javax.microedition.lcdui.Command backCommand
Back command.

Constructor Detail

Main

public Main()
Constructor.

Method Detail

startApp

public void startApp()
Enters the active state. Shows a list of samples that the user can select for execution.

Specified by:
startApp in class javax.microedition.midlet.MIDlet

pauseApp

public void pauseApp()
Enters the paused state.

Specified by:
pauseApp in class javax.microedition.midlet.MIDlet

destroyApp

public void destroyApp(boolean unconditional)
Enters the destroyed state.

Specified by:
destroyApp in class javax.microedition.midlet.MIDlet
Parameters:
unconditional - if true, MIDlet is required to exit unconditionally.

switchSample

private void switchSample(Sample newSample)
Destroys the current sample if it exists and displays a new one. Argument can be null to indicate that no new sample should be displayed.

Parameters:
newSample - new sample to display or null to simply destroy the current sample if it exists.

commandAction

public void commandAction(javax.microedition.lcdui.Command command,
                          javax.microedition.lcdui.Displayable displayable)
Receives command actions from the selection screen as well as the samples.

Specified by:
commandAction in interface javax.microedition.lcdui.CommandListener
Parameters:
command - command.
displayable - source of the command.