/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
//Nama : Surya Kharisma Karnefo
//NoBP : 10101152630292
//Kelas: IF-7
//Mobail Programing
/**
* @author 9niNEFOur4
*/
public class Tugas extends MIDlet implements CommandListener{
private Display layar;
private Form formUtama,f2;
private Command cmdKeluar,cmdKembali,cmdProses;
private Image img;
private TextField txtSisi;
public Tugas (){
layar=Display.getDisplay(this);
formUtama=new Form("Halaman Utama");
cmdKeluar=new Command("Keluar",Command.EXIT,0);
cmdProses=new Command("Proses",Command.OK,1);
try{
img=Image.createImage("/sisi.png");
}catch(Exception e){
System.out.println("Gambar Tidak Ada");
}
txtSisi=new TextField("panjang sisi = ","",10,TextField.NUMERIC);
formUtama.append(txtSisi);
formUtama.setTicker(new Ticker ("9niNEFOur4"));
formUtama.addCommand(cmdKeluar);
formUtama.addCommand(cmdProses);
formUtama.append(img);
formUtama.setCommandListener(this);
}
public void startApp() {
layar.setCurrent(formUtama);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction (Command c, Displayable s){
if(c==cmdKeluar){
destroyApp(true);
notifyDestroyed();
}else if(c==cmdProses){
int Sisi,Luas;
Sisi=Integer.parseInt(txtSisi.getString());
Luas=Sisi*Sisi;
f2=new Form("Hasil");
cmdKembali=new Command("Kembali",Command.BACK,0);
f2.addCommand(cmdKembali);
f2.append("Sisi:"+txtSisi.getString()+"\n");
f2.append("Luas:"+Luas);
layar.setCurrent(f2);
f2.setCommandListener(this);
}else if(s==f2);
if(c==cmdKembali){
layar.setCurrent(formUtama);
}
}
}
Tidak ada komentar:
Posting Komentar