public class MIDlet1 extends MIDlet implements CommandListener { PRivate Display display; // Reference to Display object private TextBox tbxMain; // A Textbox to display a message private Command cmdExit; // A Command to exit the MIDlet
// The constrUCtor public MIDlet1() { display = Display.getDisplay(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) { }
// Check to see if our Exit command was selected public void commandAction(Command c, Displayable s) { if (c == cmdExit) { destroyApp(false); notifyDestroyed(); } } }
public class MIDlet2 extends MIDlet implements CommandListener { private Display display; // Reference to Display object private Form frmMain; // The main form private TextField txfName; // A text field to prompt for name private Command cmdExit; // A Command to exit the MIDlet
// The constructor public MIDlet2() { display = Display.getDisplay(this);
cmdExit = new Command("Exit", Command.SCREEN, 1);
txfName = new TextField("Name:", "", 10, TextField.ANY);
frmMain = new Form("Sample Form"); frmMain.addCommand(cmdExit); frmMain.append(txfName); frmMain.setCommandListener(this); }
// Called by application manager to start the MIDlet. public void startApp() { display.setCurrent(frmMain); }
// A required method public void pauseApp() { }
// A required method public void destroyApp(boolean unconditional) { }
// Check to see if our Exit command was selected public void commandAction(Command c, Displayable s) { if (c == cmdExit) { destroyApp(false); notifyDestroyed(); } } }