Membuat aplikasi radio button pada j2m3

Hey temen semua dah lama ni aq gk posting blog q.Ya kali ni q sempetin posting buat blog q ya moga ja postingan q ni bisa da manfaatx buat kalian semua.Langsung ja ya.Postingan kali ini q mau posting mengenai pemrograman java mobile atau bisa disebut j2me nah kita mau belajar bikin radio button langsung ja dah q kasi source codex :

import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;

public class RadioButton extends MIDlet implements CommandListener{

    private Display display;

    private Command exit, submit;

    private List list;


    public RadioButton(){

    exit = new Command(“Exit”,Command.EXIT, 1);

    submit = new Command(“Simpan”,Command.SCREEN, 2);

    list = new List(“Jenis Kelamin”,List.EXCLUSIVE);


    }


    public void startApp(){

    display = Display.getDisplay(this);

    list.append(“Pria”, null);

    list.append(“Wanita”, null);

    list.append(“Banci”, null);

    list.addCommand(exit);

    list.addCommand(submit);

    list.setCommandListener(this);

    display.setCurrent(list);

    }


    public void pauseApp(){}


    public void destroyApp(boolean kondisi){

    notifyDestroyed();

    }


    public void showMsg(){

    Alert alert = new Alert(“Pilihan”,list.getString(list.getSelectedIndex()), null, null);

    display.setCurrent(alert);

    list.removeCommand(submit);

    }


    public void commandAction(Command c, Displayable Displayable){

    String label = c.getLabel();

    if(label.equals(“Simpan”)){

    showMsg();

    }else if (label.equals(“Exit”)){

    destroyApp(false);

    }

    }

}

Berikut adalah ruuning programnya :

Iklan

About miftafebrian

oke coy......

Posted on Mei 21, 2012, in Java. Bookmark the permalink. Tinggalkan komentar.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: