import javax.microedition.midlet.*; import javax.microedition.lcdui.*; /** * @author Didik Kurniawan * Jurusan Ilmu Komputer FMIPA Universitas Lampung */ public class AgenPulsa extends MIDlet implements CommandListener{ List namaOperator; List telkomsel, indosat,xl,three; Display display; Command ok =new Command("OK",Command.OK,0); Command exit =new Command("Exit",Command.EXIT,0); Command kembali =new Command("Back",Command.BACK,0); Command kirim = new Command("Kirim",Command.OK,0); Form form=new Form("No Tujuan"); TextField noTujuan=new TextField(null,null,32,TextField.PHONENUMBER); public AgenPulsa(){ namaOperator=new List("Operator",List.IMPLICIT); namaOperator.append("Telkomsel", null); namaOperator.append("Indosat", null); namaOperator.append("XL", null); namaOperator.append("Three", null); namaOperator.addCommand(ok); namaOperator.addCommand(exit); namaOperator.setCommandListener(this); telkomsel=new List("Telkomsel",List.IMPLICIT); telkomsel.append("5K",null); telkomsel.append("10K",null); telkomsel.append("20K",null); telkomsel.append("25K",null); telkomsel.append("50K",null); telkomsel.append("100K",null); telkomsel.addCommand(ok); telkomsel.addCommand(exit); telkomsel.addCommand(kembali); telkomsel.setCommandListener(this); indosat=new List("Indosat",List.IMPLICIT); indosat.append("2K",null); indosat.append("5K",null); indosat.append("10K",null); indosat.append("25K",null); indosat.append("50K",null); indosat.append("100K",null); indosat.addCommand(ok); indosat.addCommand(exit); indosat.addCommand(kembali); indosat.setCommandListener(this); xl=new List("XL",List.IMPLICIT); xl.append("1K",null); xl.append("5K",null); xl.append("10K",null); xl.append("25K",null); xl.append("50K",null); xl.append("100K",null); xl.addCommand(ok); xl.addCommand(exit); xl.addCommand(kembali); xl.setCommandListener(this); three=new List("Three",List.IMPLICIT); three.append("1K",null); three.append("2K",null); three.append("3K",null); three.append("4K",null); three.append("5K",null); three.append("10K",null); three.append("20K",null); three.append("30K",null); three.append("50K",null); three.append("100K",null); three.addCommand(ok); three.addCommand(exit); three.addCommand(kembali); three.setCommandListener(this); form.append("Isi Pulsa"); form.append(noTujuan); form.addCommand(ok); form.addCommand(kembali); form.addCommand(kirim); form.addCommand(exit); form.setCommandListener(this); } public void startApp() { if (display==null){ display=Display.getDisplay(this); display.setCurrent(namaOperator); } } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void commandAction(Command c, Displayable d ){ if (c==exit) { destroyApp(true); notifyDestroyed(); } else if(c==ok && d==namaOperator){ if (namaOperator.getSelectedIndex()==0) { display.setCurrent(telkomsel); } else if (namaOperator.getSelectedIndex()==1){ display.setCurrent(indosat); } else if (namaOperator.getSelectedIndex()==2){ display.setCurrent(xl); } else if (namaOperator.getSelectedIndex()==3){ display.setCurrent(three); } } else if(c==kembali && (d==telkomsel || d==indosat || d==xl || d==three)){ display.setCurrent(namaOperator); } else if(c==kembali && d==form){ display.setCurrent(namaOperator); } else if (c==ok && (d==telkomsel || d==indosat || d==xl || d==three)){ display.setCurrent(form); } } }