import java.io.*; import javax.microedition.lcdui.*; import javax.microedition.midlet.*;
public class mymenu extends MIDlet implements CommandListener { private List mymenu, msgsmenu, conmenu, callregmenu, setmenu, clomenu, remindersmenu, games, exmenu; private Command exit, next, back; private String[] mymenuElements = { "Messages","Contacts","Call Register","Settings","Clock","Reminders","Games","Extras"}; private Image[] image = {loadImage("/MESSAGES.jpg"),loadImage("/CONTACTS.jpg"),loadImage("/CALLR EGISTER.jpg"),loadImage("/SETTING.jpg"),loadImage("/CLOCK.jpg"),loadImage("/ REMINDERS.jpg"),loadImage("/GAMES.jpg"),loadImage("/EXTRAS.jpg")};
private Alert alert; public mymenu() { String[] msgs = {"Create Message", "Inbox", "Sent Items", "Drafts", "Chat", "Picture Messages", "Distribution Lists", "Screened Messages", "Delete Messages", "Message Counter", "Message Settings", "Service Command Editor" }; String[] contacts = {"Search", "Add Contact", "Delete", "Copy", "Settings", "Speed Dial", "No.Screening"}; String[] call = {"Missed Calls", "Received Calls", "Dialled Numbers", "Delete Recent Call Lists", "Call Duration", "Message Counter"}; String[] settings = {"Tone Settings", "Display Settings", "Profiles", "Time Settings", "Call Settings", "Phone Settings", "Cost Settings", "Enhancement Settings", "Security Setting",
"Right Selection Key Settings", "Restore Factory Settings"}; String[] alarmclock = {"Alarm Time", "Alarm Tone", "Repeat Alarm", "Speaking Clock", "Time Settings"}; String[] reminders = {"Add New", "View All", "Delete", "Alarm Tone"}; String[] gamesmenu = {"Pocket Carrom", "Snake", "Settings"}; String[] extras = {"Calculator", "Converter", "Countdown Timer", "Stopwatch", "Composer", "Chinese Lunar Calendar", "Demo"};
msgsmenu = new List("Messages", List.IMPLICIT, msgs,null); conmenu = new List("Contacts", List.IMPLICIT, contacts, null); callregmenu = new List("Call Register", List.IMPLICIT, call, null); setmenu = new List("Settings", List.IMPLICIT, settings, null); clomenu = new List("Alarm Clock", List.IMPLICIT, alarmclock, null); remindersmenu = new List("Reminders", List.IMPLICIT, reminders, null); games = new List("Games", List.IMPLICIT, gamesmenu, null); exmenu = new List("Extras", List.IMPLICIT, extras, null);
mymenu = new List("mymenu",List.IMPLICIT,mymenuElements,image);
next = new Command("Next", Command.OK, 0); exit = new Command("Exit", Command.EXIT, 0); back = new Command("Back", Command.BACK, 0);
msgsmenu.addCommand(back); msgsmenu.addCommand(next); msgsmenu.setCommandListener(this);
conmenu.addCommand(back);
conmenu.addCommand(next); conmenu.setCommandListener(this);
callregmenu.addCommand(back); callregmenu.addCommand(next); callregmenu.setCommandListener(this);
setmenu.addCommand(back); setmenu.addCommand(next); setmenu.setCommandListener(this);
clomenu.addCommand(back); clomenu.addCommand(next); clomenu.setCommandListener(this);
remindersmenu.addCommand(back); remindersmenu.addCommand(next); remindersmenu.setCommandListener(this);
games.addCommand(back); games.addCommand(next); games.setCommandListener(this);
exmenu.addCommand(back); exmenu.addCommand(next); exmenu.setCommandListener(this);
mymenu.addCommand(next);
mymenu.addCommand(exit); mymenu.setCommandListener(this); }
public void startApp() { Display.getDisplay(this).setCurrent(mymenu); } public void commandAction(Command c, Displayable s) { if(/*c==next || */c == List.SELECT_COMMAND) { if(mymenu.getSelectedIndex()==0) { Display.getDisplay(this).setCurrent(msgsmenu);
if(msgsmenu.isShown()) { int index = msgsmenu.getSelectedIndex(); Alert alert = new Alert("Your Selection", "You choose: " + msgsmenu.getString(index), null, AlertType.ALARM); Display.getDisplay(this).setCurrent(alert); }
} else if(mymenu.getSelectedIndex()==1) {
Display.getDisplay(this).setCurrent(conmenu); if(conmenu.isShown()) { int index = conmenu.getSelectedIndex(); Alert alert = new Alert("Your Selection", "You choose: " + conmenu.getString(index), null, AlertType.ALARM); Display.getDisplay(this).setCurrent(alert); }
} else if(mymenu.getSelectedIndex()==2) { Display.getDisplay(this).setCurrent(callregmenu); if(callregmenu.isShown()) { int index = callregmenu.getSelectedIndex(); Alert alert = new Alert("Your Selection", "You choose: " + callregmenu.getString(index), null, AlertType.ALARM); Display.getDisplay(this).setCurrent(alert); }
} else if(mymenu.getSelectedIndex()==3) {
Display.getDisplay(this).setCurrent(setmenu); if(setmenu.isShown()) {
int index = setmenu.getSelectedIndex(); Alert alert = new Alert("Your Selection", "You choose: " + setmenu.getString(index), null, AlertType.ALARM); Display.getDisplay(this).setCurrent(alert); }
} else if(mymenu.getSelectedIndex()==4) {
Display.getDisplay(this).setCurrent(clomenu); if(clomenu.isShown()) { int index = clomenu.getSelectedIndex(); Alert alert = new Alert("Your Selection", "You choose: " + clomenu.getString(index), null, AlertType.ALARM); Display.getDisplay(this).setCurrent(alert); }
} else if(mymenu.getSelectedIndex()==5) { Display.getDisplay(this).setCurrent(remindersmenu); if(remindersmenu.isShown()) { int index = remindersmenu.getSelectedIndex(); Alert alert = new Alert("Your Selection", "You choose: " + remindersmenu.getString(index), null, AlertType.ALARM); Display.getDisplay(this).setCurrent(alert);
}
} else if(mymenu.getSelectedIndex()==6) { Display.getDisplay(this).setCurrent(games); if(games.isShown()) { int index = games.getSelectedIndex(); Alert alert = new Alert("Your Selection", "You choose: " + games.getString(index), null, AlertType.ALARM); Display.getDisplay(this).setCurrent(alert); } } else if(mymenu.getSelectedIndex()==7) { Display.getDisplay(this).setCurrent(exmenu); if(exmenu.isShown()) { int index = exmenu.getSelectedIndex(); Alert alert = new Alert("Your Selection", "You choose: " + exmenu.getString(index), null, AlertType.ALARM); Display.getDisplay(this).setCurrent(alert); } } } else if(c==exit) notifyDestroyed();
else if(c==back) Display.getDisplay(this).setCurrent(mymenu); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } private Image loadImage(String name) { Image image = null; try { image = Image.createImage(name); } catch(IOException ioe) { System.out.println(ioe); } return image; } }