// En MIDlet som visar en textruta och ett Exit-kommando import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class Kommandotest extends MIDlet { private Display displayen; private TextBox textrutan; private Command exitkommandot; public Kommandotest() { } public void destroyApp(boolean unconditional) { } public void pauseApp() { } public void startApp() { textrutan = new TextBox("Hej!", "Hej, världen!", 20, 0); exitkommandot = new Command("Exit", Command.EXIT, 0); textrutan.addCommand(exitkommandot); Exitkommandolyssnare lyssnaren = new Exitkommandolyssnare(); textrutan.setCommandListener(lyssnaren); displayen = Display.getDisplay(this); displayen.setCurrent(textrutan); } class Exitkommandolyssnare implements CommandListener { public void commandAction(Command c, Displayable s) { notifyDestroyed(); } } }