// This package defines MIDP applications and the interactions
// between the application and the environment in which the
// application runs.
import javax.microedition.midlet.*;
// This package provides a set of features for implementation
// of user interfaces.
import javax.microedition.lcdui.*;
public class HelloMIDlet
extends MIDlet
implements CommandListener {
private Display display;
private TextBox tbxMain;
private Command cmdExit;
// MIDlet constructor
public HelloMIDlet( ) {
display = Display.getDisplay( this );
cmdExit = new Command( "Exit", Command.SCREEN, 1 );
tbxMain = new TextBox( "HelloMIDlet", "Hello, World!", 50, 0 );
tbxMain.addCommand( cmdExit );
tbxMain.setCommandListener( this );
}
// Called by application manager to start the MIDlet
public void startApp( ) {
display.setCurrent( tbxMain );
}
// A required method
public void pauseApp( ) { }
// A required method
public void destroyApp( boolean unconditional ) { }
// Destroy the MIDlet if the Exit command was selected.
public void commandAction( Command c, Displayable s ) {
if ( c == cmdExit ) {
destroyApp( false );
notifyDestroyed( );
}
}
}
|