Tutorial Java Mobile, Membuat Choice

Kali ini saya akan membuat Java Mobile Choice.. kurang lebih hasil seperti gambar di bawah

Untuk Aplikasinya Saya memakai Netbens untuk versi saya kira semua sama saja. 

Langsung saja doble clik Netben Anda dan buat project baru dengan :
Judul Project : ChoiceEx
Nama file MIDlet  : ChoiceExample
Nama Package :Choice

Prhatian : untuk huruf (kecil, Besar, tanda titik koma atau yang lainnya di perhatikan) karena pemrograman Java merupakan bahasa program yang case sensitive.

Langsung aja Syntax dari programnya : 

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

package Choice;

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

/**
 * @author Iskan
 */
public class ChoiceEx extends MIDlet implements CommandListener {
        Display display; Form choiceForm;
    Command exitCommand = new Command("Exit", Command.EXIT, 1);
    ChoiceGroup choiceExclusive, choiceMultiple, choicePopup;

    public ChoiceEx(){
    choiceForm = new Form("Grup Tipe Pemilihan");
    choiceForm.addCommand(exitCommand);
    choiceForm.setCommandListener(this);

    choiceExclusive = new ChoiceGroup("Jns Kel (Exclusive)", Choice.EXCLUSIVE);
    choiceExclusive.append("Laki-laki", null);
    choiceExclusive.append("Perempuan", null);
    choiceForm.append(choiceExclusive);

    choiceMultiple = new ChoiceGroup("Buah (Multiple)", Choice.MULTIPLE);
    choiceMultiple.append("Apel", null);
    choiceMultiple.append("Mangga", null);
    choiceMultiple.append("Jeruk", null);
    choiceForm.append(choiceMultiple);

    choicePopup = new ChoiceGroup("Benua (Popup)", Choice.POPUP);

    choicePopup.append("Asia", null);
    choicePopup.append("Eropa", null);
    choicePopup.append("Australia", null);
    choiceForm.append(choicePopup);

    }

    public void startApp() {
        if (display == null){
            display = Display.getDisplay(this);
            display.setCurrent(choiceForm);
        }
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

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

 Penting :

Judul Project, Nama file MIDle, Nama Package harus sesuai dengan di atas. Juka tidak Syntax akan eror.

Terima kasih atas perhatiannya. Selamat Bercoding. Semoga bermanfaat :)



Komentar

Postingan populer dari blog ini

Diagram Use Case Dan Use Case Description

Beberapa Website Keren Yang bisa Bikin Kita Cerdas

Apa itu SKPL Dan Kebutuhan Perangkat Lunak ?