BLOGGER TEMPLATES - TWITTER BACKGROUNDS »

Jumat, 23 Maret 2012

tugas2

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;


public class Praktek4 extends MIDlet implements CommandListener{
    private Display layar;
    private Command cmdKeluar,cmdProses;
    private Image img;
    private ImageItem ii;
    private Command cmdmasuk;
    private Form formUtama;
   
    //deklarasi variable untuk form ke 2
    Form f2;
    TextField nama,psswd;
    Command CmdKembali,cmdProses1;
    private Command cmdKembali;
   
    //Form 3
    Form f3;
    TextField a,b;
    ChoiceGroup cgop;
    Command cmdKembali2,cmdProses2;
    private StringItem hasil;
   
   
    public Praktek4(){
        layar=Display.getDisplay(this);
        formUtama=new Form("FORM UTAMA");
        cmdKeluar=new Command("Keluar", Command.EXIT,0);
        cmdProses=new Command("Masuk", Command.OK,1);
        try{
            img=Image.createImage("/alam.jpeg");
        }catch(Exception e){
            System.out.println("Gambar tidak ada" +e);
        }
        ii=new ImageItem(" ",img , Item.LAYOUT_CENTER, "Gambar Saya");
        formUtama.addCommand(cmdKeluar);
        formUtama.addCommand(cmdProses);
        formUtama.append(ii);
        formUtama.setTicker(new Ticker("Welcome to nofriadi"));
        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){
            f2=new Form("LOGIN");
            CmdKembali=new Command("Back",Command.BACK,0);
            cmdProses1=new Command("Login",Command.OK,1);
            nama =new TextField("User Name","", 20,TextField.ANY);
            psswd=new TextField("Password","", 20, TextField.ANY);
            f2.addCommand(CmdKembali);
            f2.addCommand(cmdProses1);
            f2.append(nama);
            f2.append(psswd);
            f2.setCommandListener(this);
            layar.setCurrent(f2);
         }else if (s==f2){
            if(c==CmdKembali){
            layar.setCurrent(formUtama);
             }
          else if(c==cmdProses1){
            f3=new Form("HITUNG");
            a=new TextField("Nilai A","", 20, TextField.ANY);
            b=new TextField("Nilai B","", 20, TextField.ANY);
            cgop=new ChoiceGroup("Operator", Choice.IMPLICIT);
            cgop.append("X", null);
            cgop.append("/", null);
            cgop.append("+", null);
            cgop.append("-", null);
            f3.addCommand(cmdKembali2);
            f3.addCommand(cmdProses2);
            f3.append(a);
            f3.append(b);
            f3.append(cgop);
            f3.setCommandListener(this);
            layar.setCurrent(f3);
            }
           
           
        
        
    }
}
}

0 komentar: