/*
* To change this
template, choose Tools | Templates
* and open the
template in the editor.
*/
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.*;
/**
* @author user
*/
public class Programkeempat extends MIDlet implements
CommandListener{
Display display;
Form form;
Form form2;
TextField txtNama;
TextField txtNPM;
TextField txtKelas;
TextField txtHobi;
TextField
txtCitacita;
TextField
txtAngkapertama;
TextField
txtAngkaKedua;
Command cmdkeluar;
Command cmdsimpan;
public
Programkeempat(){
display =
Display.getDisplay(this);
form = new
Form("Pengisian Data");
form2 = new
Form("");
txtNama = new
TextField("Nama", null, 10, TextField.ANY);
txtNPM = new
TextField("NPM", null, 25, TextField.NUMERIC);
txtKelas = new
TextField("Kelas", null, 10, TextField.ANY);
txtHobi = new
TextField("Hobi", null, 20, TextField.ANY);
txtCitacita =
new TextField("Cita-Cita", null, 30, TextField.ANY);
txtAngkapertama
= new TextField("Angkaperta", null, 25,TextField.ANY);
txtAngkaKedua =
new TextField("Angkakedua", null, 15, TextField.ANY);
cmdkeluar = new
Command("Keluar", Command.EXIT, 1);
cmdsimpan = new
Command("Simpan", Command.OK, 1);
form.append(txtNama);
form.append(txtNPM);
form.append(txtKelas);
form.append(txtHobi);
form.append(txtCitacita);
form.append(txtAngkapertama);
form.append(txtAngkaKedua);
form.addCommand(cmdkeluar);
form.addCommand(cmdsimpan);
form.setCommandListener(this);
form2.setCommandListener(this);
}
public void
startApp() {
display.setCurrent(form);
}
public void pauseApp()
{
}
public void
destroyApp(boolean unconditional) {
}
public void
commandAction(Command c, Displayable d) {
if(c==cmdkeluar){
destroyApp(false);
this.notifyDestroyed();
}
else
if(c==cmdsimpan){
form2.append(txtNama.getString() +"\n");
form2.append(txtNPM.getString() +"\n");
form2.append(txtKelas.getString() +"\n");
form2.append(txtHobi.getString() +"\n");
form2.append(txtCitacita.getString()
+"\n");
int i =
Integer.parseInt(txtAngkapertama.getString());
int j =
Integer.parseInt(txtAngkaKedua.getString());
int jumlah
= i + j;
form2.append("Angka Pertama : " + i + "\n");
form2.addCommand(cmdkeluar);
display.setCurrent(form2);
}
}
}
Tidak ada komentar:
Posting Komentar