import javax.microedition.midlet.*; import javax.microedition.lcdui.*; /** * @author Jerome Locson */ public class MenuList extends MIDlet implements CommandListener { Display display = null; List menu = null; Alert alert = null; static Command menuCommand = new Command("Menu", Command.SCREEN, 0); static Command exitCommand = new Command("Exit", Command.STOP, 1); public void startApp() { display = Display.getDisplay(this); menu = new List("Menu", Choice.IMPLICIT); menu.append("Adobo", null); menu.append("Pinakbet", null); menu.append("Siomai", null); menu.append("Leche Flan", null); menu.append("Halo-Halo", null); menu.addCommand(exitCommand); menu.setCommandListener(this); display.setCurrent(menu); } public void pauseApp() { } public void destroyApp(boolean unconditional) { notifyDestroyed(); } public void foodSelected() { String selection = menu.getString(menu.getSelectedIndex()); alert = new Alert("Food Selected", selection, null, null); alert.setTimeout(Alert.FOREVER); alert.setType(AlertType.INFO); display.setCurrent(alert); } public void commandAction(Command c, Displayable d) { String menuLabel = c.getLabel(); if (menuLabel.equals("Exit")) { destroyApp(true); } else { foodSelected(); } } }