// This program creates an EXIT command assigning a soft-button to it import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class AccessCommands extends MIDlet implements CommandListener { private Display display; // Reference to a display private Form fmMain; // A Form private Command cmExit; // The Exit Command // constructor public AccessCommands(){ display = Display.getDisplay(this); // instantiate the display for this MIDlet fmMain = new Form("First Command"); // new form cmExit = new Command ("Exit", Command.EXIT, 1); // new command fmMain.addCommand(cmExit); // add the Exit command to the form fmMain.setCommandListener(this); // Listen for events } // startApp public void startApp(){ display.setCurrent(fmMain); // set the current display to fmMain } // pauseApp public void pauseApp(){ // a required method } //destroyApp public void destroyApp(boolean unconditional){ // destroy method } public void commandAction(Command c, Displayable s){ // check to see if "Exit" button was selected if (c == cmExit){ destroyApp(false); notifyDestroyed(); } } }