Contoh Program J2ME (dengan nama project dan MIDlet class: MBankingBisa) LayarJumlahUang
import javax.microedition.lcdui.*;
public class LayarJumlahUang
extends Form implements CommandListener {
private MBankingBisa midlet;
private Display display;
private LayarKirimUang layar1;
private LayarJumlahUang jumlahUang;
private Alert alert;
private TextField tfJumlahUangKirim;
private Command cmdKembali, cmdHitung, cmdOk, cmdBantuan;
private String inp;
private Command cmChoice = new Command("Lanjut",Command.SCREEN,1);
private Command cmBack = new Command("Kembali",Command.BACK,0);
public LayarJumlahUang(MBankingBisa midlet, Display display){
super("Jumlah Uang");
this.display = display;
this.midlet = midlet;
tfJumlahUangKirim = new TextField("Jumlah Uang yang Akan Dikirim : ", "",20, TextField.ANY);
append(tfJumlahUangKirim);
addCommand(cmChoice);
addCommand(cmBack);
setCommandListener(this);
}
public void itemStateChanged(Item item) {
}
public void commandAction(Command c, Item item) {
}
public void commandAction (Command c, Displayable d){
if (c == cmChoice){
jumlahUang = new LayarJumlahUang(midlet,display);
display.setCurrent(jumlahUang);
} else if (c == cmBack) {
LayarKirimUang layar1 = new LayarKirimUang(midlet,display);
display.setCurrent(layar1);
}
}
private void Pesan(String judul, String pesan, AlertType tipe,
int durasi) {
alert = new Alert(judul,pesan,null,tipe);
alert.setTimeout(durasi);
Display.getDisplay(midlet).setCurrent(alert);
}
}
0 comments