Aplikasi sederhana J2ME dengan Neatbeans


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Biodata;

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

/**
 * @author atmojo.tk
 */
public class Perkenalan extends MIDlet implements CommandListener {

    private Form frm;
    private Command cmdExit, cmdProses;
    private TextField txtNama;
    private TextField txtAlamat;
    private TextField txtTahun;
    private Ticker tcr;
    private Alert alrt;
    private int a;

    public Perkenalan()
    {
        frm=new Form("Biodata");
        tcr=new Ticker("- Dedyk Suntoro Atmojo: 11201114 - Dini Yuliana Sari: 11201093 - Gita Permata Asadiana: 11201254 -");
        txtNama=new TextField("Nama: ", "", 20, TextField.ANY);
        txtAlamat=new TextField("Alamat: ", "", 50, TextField.ANY);
        txtTahun=new TextField("Tahun Lahir: ", "", 4, TextField.NUMERIC);
        cmdProses=new Command("Proses", Command.OK, 1);
        cmdExit=new Command("Keluar", Command.EXIT, 2);
    }


    public void startApp() {
        frm.setTicker(tcr);
        frm.addCommand(cmdProses);
        frm.append(txtNama);
        frm.append(txtAlamat);
        frm.append(txtTahun);
        frm.addCommand(cmdExit);
        frm.setCommandListener(this);
        Display.getDisplay(this).setCurrent(frm);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
       if(c==cmdExit)
       {
           keluar();
        }
            else if (c==cmdProses)
            {
                proses();
            }
    }

        public void proses()
        {
          a=Integer.parseInt(txtTahun.getString());
          String Hasil="Nama anda "+txtNama.getString()+". Alamat Anda di "+txtAlamat.getString()+". Usia Anda "+ (2012-a)+" Tahun.";
          alrt=new Alert("Hasil", Hasil, null, AlertType.INFO);
          alrt.setTimeout(Alert.FOREVER);
          Display.getDisplay(this).setCurrent(alrt);
        }

        public void keluar()
        {
           destroyApp(true);
           notifyDestroyed();
        }
}
◄ Posting Baru Posting Lama ►

------------------------Boost Your Website----------------------

 

Recomended


Free Chat


Copyright © . Art Media Blog - All Rights Reserved TOP