import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Absensi extends MIDlet implements CommandListener {
private Command cmdExit, cmdTampil, cmdReset;
private Form form;
private ChoiceGroup mitra;
private TextField tfId, tfNama, tfPassword, tfMitra;
private StringItem siJudul, siId, siNama, siMitra;
public Absensi(){
cmdExit = new Command("Exit", Command.EXIT, 1);
cmdTampil = new Command("Tampil", Command.SCREEN, 1);
cmdReset = new Command("Reset", Command.SCREEN, 1);
form = new Form("Absensi Karyawan");
tfId = new TextField("NIK", null, 11, TextField.NUMERIC);
tfNama = new TextField("Nama", null, 30, TextField.ANY);
tfPassword = new TextField("Password", null,30, TextField.PASSWORD);
//tfMitra = new TextField("Mitra", null, 30, TextField.ANY);
mitra = new ChoiceGroup("Pilih Mitra: ", ChoiceGroup.POPUP);
mitra.append("PT INFOMEDIA", null);
mitra.append("PT PIN", null);
mitra.append("PT BARATA", null);
mitra.append("PT RELINDO", null);
siJudul = new StringItem(null, null);
siId = new StringItem(null, null);
siNama = new StringItem(null, null);
siMitra = new StringItem(null,null);
form.append(tfId);
form.append(tfNama);
form.append(tfPassword);
form.append(mitra);
form.append(siJudul);
form.append(siId);
form.append(siNama);
form.append(siMitra);
form.addCommand(cmdExit);
form.addCommand(cmdTampil);
form.addCommand(cmdReset);
form.setCommandListener(this);
Display.getDisplay(this).setCurrent(form);
}
public void startApp(){}
public void pauseApp() {}
public void destroyApp(boolean force) {}
public void commandAction(Command c, Displayable d){
if(c == cmdExit){
destroyApp(true);
notifyDestroyed();
}else if(c == cmdTampil){
String id, nama, password,isiMitra;
id = tfId.getString();
nama = tfNama.getString();
int iMitra;
iMitra = mitra.getSelectedIndex();
isiMitra = mitra.getString(iMitra);
//Tampil data
siJudul.setLabel("SUKSES ABSENSI \n");
siId.setText("NIP : "+ id +"\n");
siNama.setText("Nama : "+ nama +"\n");
siMitra.setText("Mitra anda : "+ isiMitra +"\n");
//siMitra.setText("MItra: "+ isiMitra);
} else {
//isi form
tfId.setString(null);
tfNama.setString(null);
//mitra.setSelectedIndex(0, true);
//isi label
siJudul.setLabel(null);
siId.setLabel(null);
siNama.setLabel(null);
siMitra.setLabel(null);
}
}
}
Komentar