package com.jcomeau.midp; import javax.microedition.lcdui.*; import javax.microedition.midlet.MIDlet; public class Demo extends MIDlet implements Runnable, CommandListener { public static final int MAXEVENTS = 20; public static Demo midlet = null; Thread thread = null; DemoList demo = null; int count = 0; Display display = Display.getDisplay(this); public void startApp() { (thread = new Thread(this)).start(); midlet = this; } public void run() { demo = new DemoList(); display.setCurrent(demo); } public void die() { notifyDestroyed(); while (thread.isAlive()) try {thread.join();} catch (Exception ignored) {} } public void pauseApp() {} public void destroyApp(boolean flag) {} public void commandAction(Command command, Displayable source) { Common.debug("received command"); if (demo.size() == MAXEVENTS) demo.delete(MAXEVENTS - 1); demo.insert(1, "command " + ++count + ": \"" + command.getLabel() + "\", type " + command.getCommandType() + " from " + source, null); } }