FileDocCategorySizeDatePackage
HelloMIDlet.javaAPI DocJ2ME MIDP 2.02301Thu Nov 07 12:02:16 GMT 2002None

HelloMIDlet

public class HelloMIDlet extends MIDlet implements CommandListener
An example MIDlet with simple "Hello" text and an exit command.

Fields Summary
private Command
exitCommand
private TextBox
textBox
private Display
display
Constructors Summary
public HelloMIDlet()
Constructs the HelloMIDlet, its screen, and its command. It associates the screen and command, and caches the MIDlets display.

        // Create the abstract command
        exitCommand = new Command("Exit", Command.EXIT, 1);

        // Create the screen and give it a command and a listener
        textBox = new TextBox("Hello MIDlet", "Test string",
                              256, TextField.ANY | TextField.UNEDITABLE);
        textBox.addCommand(exitCommand);
        textBox.setCommandListener(this);

        // Set the MIDlet's display to its initial screen
        display = Display.getDisplay(this);
        display.setCurrent(textBox);
    
Methods Summary
public voidcommandAction(Command command, Displayable screen)

        if (command == exitCommand) {
            destroyApp(false);
            notifyDestroyed();
        }
    
public voiddestroyApp(boolean unconditional)
Destroys the MIDlet; this method does nothing because there is nothing to cleanup that is not handled by the garbage collector.

    
public voidpauseApp()
Pauses the MIDlet; this method does nothing because there are no background activities or shared resources to close.

    
public voidstartApp()
Starts the MIDlet; this method does nothing because the MIDlet does not require any shared resources.