FirstChoiceGroup.java |
import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class FirstChoiceGroup extends MIDlet implements CommandListener { Display display; FirstChoiceGroupForm form; List list; Command cmExit; public FirstChoiceGroup() { display = Display.getDisplay(this); } public void startApp() { list = new List("First ChoiceGroup", List.IMPLICIT); list.append("EXCLUSIVE", null); list.append("MULTIPLE", null); list.append("POPUP", null); list.append("TEXT WRAP OFF", null); list.append("TEXT WRAP ON", null); cmExit = new Command("Keluar", Command.EXIT, 1); list.addCommand(cmExit); list.setCommandListener(this); display.setCurrent(list); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void exitMIDlet() { destroyApp(false); notifyDestroyed(); } public void commandAction(Command c, Displayable s){ if (c == List.SELECT_COMMAND){ switch (list.getSelectedIndex()){ case 0: form = new FirstChoiceGroupForm(this, display, 0); display.setCurrent(form); break; case 1: form = new FirstChoiceGroupForm(this, display, 1); display.setCurrent(form); break; case 2: form = new FirstChoiceGroupForm(this, display, 2); display.setCurrent(form); break; case 3: form = new FirstChoiceGroupForm(this, display, 3); display.setCurrent(form); break; case 4: form = new FirstChoiceGroupForm(this, display, 4); display.setCurrent(form); break; } }else if(c == cmExit){ exitMIDlet(); } } }; |
FirstChoiceGroupForm.java |
import javax.microedition.lcdui.*; class FirstChoiceGroupForm extends Form implements CommandListener { private Display display; private Command cmBack, cmExit; private FirstChoiceGroup midlet; private ChoiceGroup cgEx, cgMu, cgPo, cgTf, cgTn; public FirstChoiceGroupForm(FirstChoiceGroup midlet, Display display, int choice) { super("First ChoiceGroup"); this.display = display; this.midlet = midlet; switch (choice){ case 0: cgEx = new ChoiceGroup("EXCLUSIVE", Choice.EXCLUSIVE); cgEx.append("string 1", null); cgEx.append("string 2", null); cgEx.append("string 3", null); append(cgEx); break; case 1: cgMu = new ChoiceGroup("MULTIPLE", Choice.MULTIPLE); cgMu.append("string 1", null); cgMu.append("string 2", null); cgMu.append("string 3", null); append(cgMu); break; case 2: cgPo = new ChoiceGroup("POPUP", Choice.POPUP); cgPo.append("string 1", null); cgPo.append("string 2", null); cgPo.append("string 3", null); append(cgPo); break; case 3: cgTf = new ChoiceGroup("TEXT WRAP OFF", Choice.TEXT_WRAP_OFF); cgTf.append("text wrap off striiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiing 1", null); cgTf.append("text wrap off striiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiing 2", null); cgTf.append("text wrap off striiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiing 3", null); append(cgTf); break; case 4: cgTn = new ChoiceGroup("TEXT WRAP ON", Choice.TEXT_WRAP_ON); cgTn.append("text wrap on striiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiing 1", null); cgTn.append("text wrap on striiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiing 2", null); cgTn.append("text wrap on striiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiing 3", null); append(cgTn); break; } cmBack = new Command("Kembali", Command.BACK, 1); addCommand(cmBack); cmExit = new Command("Keluar", Command.EXIT, 1); addCommand(cmExit); setCommandListener(this); } public void commandAction(Command c, Displayable s){ if (c == cmBack) { display.setCurrent(midlet.list); }else if (c == cmExit) { midlet.exitMIDlet(); } } } |
Rabu, 29 April 2009
FirstChoiceGroup
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar