import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class DemoChoiceGroup extends MIDlet
implements CommandListener {
private Display display;
private List list;
private Form form;
private ChoiceGroup menu;
private String[] daftarMenu = {
"Pilihan pertama",
"Pilihan kedua",
"Pilihan ketiga",
"Pilihan keempat"
};
private final Command cmdKeluar =
new Command("Keluar", Command.EXIT, 1);
private final Command cmdOK = new Command("OK", Command.OK, 1);
private final Command cmdKembali =
new Command("Kembali", Command.BACK, 1);
public DemoChoiceGroup() {
display = Display.getDisplay(this);
form = new Form("Demo ChoiceGroup");
form.addCommand(cmdKembali);
form.setCommandListener(this);
}
public void startApp() {
list = new List("Demo ChoiceGroup", Choice.IMPLICIT);
list.append("Tipe EXCLUSIVE", null);
list.append("Tipe MULTIPLE", null);
list.append("Tipe POPUP", null);
list.addCommand(cmdKeluar);
list.addCommand(cmdOK);
list.setCommandListener(this);
display.setCurrent(list);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
if (c == cmdKeluar) {
destroyApp(false);
notifyDestroyed();
} else if (c == cmdKembali) {
display.setCurrent(list);
} else {
menu = null;
switch (list.getSelectedIndex()) {
case 0: {
menu = new ChoiceGroup("Tipe EXCLUSIVE",
Choice.EXCLUSIVE, daftarMenu, null);
break;
}
case 1: {
menu = new ChoiceGroup("Tipe MULTIPLE",
Choice.MULTIPLE, daftarMenu, null);
break;
}
case 2: {
menu = new ChoiceGroup("Tipe POPUP",
Choice.POPUP, daftarMenu, null);
break;
}
}
form.deleteAll();
form.append(menu);
display.setCurrent(form);
}
}
}
kalo memanfaatkan file txt sebagai databases gimana caranya ya?
ReplyDelete