Showing posts with label Java ME. Show all posts
Showing posts with label Java ME. Show all posts

Materi Choice Group dalam java ME (NetBeans)

By Atmojo | At 17:17:00 | Label : , , | 0 Comments
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pilihan;

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

/**
 * @author Lab A
 */
public class Pilih extends MIDlet implements CommandListener {
    private ChoiceGroup cg;
    private Form frm;
    private Command cKeluar, cPilih;

    public Pilih()
    {
        cg=new ChoiceGroup("Pilihan", Choice.EXCLUSIVE);
        frm=new Form("Kartu Seluler");
        cKeluar=new Command("Keluar", Command.EXIT, 1);
        cPilih=new Command("Pilih", Command.OK, 2);
    }

    public void startApp() {
        cg.append("Simpati", null);
        cg.append("IM3", null);
        cg.append("XL", null);
        cg.append("Mentari", null);
        frm.addCommand(cPilih);
        frm.addCommand(cKeluar);
        frm.setCommandListener(this);
        frm.append(cg);
        Display.getDisplay(this).setCurrent(frm);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
        if (c==cKeluar)
        {
            metu();
        }
    }
    public void metu()
    {
        destroyApp(true);
        notifyDestroyed();
    }
}

Aplikasi sederhana J2ME dengan Neatbeans

By Atmojo | At 10:01:00 | Label : , , | 0 Comments
/*
 * 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 Lama ►

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

 

Recomended


Free Chat


Copyright © . Art Media Blog - All Rights Reserved TOP