Monday, December 3, 2012
SOURCE CODE Menggunakan objek DateField pada JAVA (J2ME)
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class DemoDateField extends MIDlet
implements CommandListener {
private Display display;
private List list;
private Form form;
private DateField datefield;
private String judulForm;
private String[] daftarMenu = {
"Tipe DATE",
"Tipe TIME",
"Tipe DATE_TIME"
};
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 DemoDateField() {
display = Display.getDisplay(this);
form = new Form("Demo DateField");
form.addCommand(cmdKembali);
form.setCommandListener(this);
}
public void startApp() {
list = new List("Demo DateField", Choice.EXCLUSIVE,
daftarMenu, 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 {
datefield = null;
switch (list.getSelectedIndex()) {
case 0: {
datefield = new DateField("Tipe DATE",
DateField.DATE);
break;
}
case 1: {
datefield = new DateField("Tipe TIME",
DateField.TIME);
break;
}
case 2: {
datefield = new DateField("Tipe DATE_TIME",
DateField.DATE_TIME);
break;
}
}
form.deleteAll();
form.append(datefield);
display.setCurrent(form);
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment