/* This midlet displays a static label and a text message. A user can not change either the label or text as result. StringItem does not recognise events*/ import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class myLabelText extends MIDlet implements CommandListener { private Display display; // a display private Form fmMain; // Main form private Command cmExit; // exit Command private Command cmNext; // next label and message private StringItem siUser; // the message public myLabelText() { display = Display.getDisplay(this); // Create text message and commands siUser = new StringItem("UserId: ", "myName"); cmExit = new Command("Exit", Command.EXIT, 1); cmNext = new Command("Next", Command.SCREEN, 1); // Create form, buttons and lesten for events fmMain = new Form("My String"); fmMain.addCommand(cmExit); fmMain.addCommand(cmNext); fmMain.append(siUser); fmMain.setCommandListener(this); } // start app public void startApp() { display.setCurrent(fmMain); } // pause app public void pauseApp(){ } // destroy app public void destroyApp(boolean unconditional){ } public void commandAction(Command c, Displayable s){ if (c == cmExit) { destroyApp(false); notifyDestroyed(); } else if (c == cmNext){ // this method is inheritted from the Item class siUser.setLabel("User Id #: "); // remove the next command fmMain.removeCommand(cmNext); } } }