Halaman

Kamis, 21 Maret 2013

Task 1 Java Mobile Programming


Make program MIDlet Simple with use NetBeans Mobility Pack


Input Program

package hello;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class TaskMidlet extends MIDlet implements CommandListener {
    Display display;
    Form mainForm;
    StringItem helloAlertString;
    Command exitCommand = new Command ("Exit", Command.EXIT,1);
    Command whyCommand = new Command ("Why", Command.OK,1);
    Command backCommand = new Command ("Back", Command.BACK,1);
    Alert helloAlert;

    public TaskMidlet (){
        helloAlertString = new StringItem("Selamat Belajar ","Java Mobile Programming");
        mainForm = new Form("Minka Prayogo S", new Item[] { helloAlertString});
        mainForm.addCommand(exitCommand);
        mainForm.addCommand(whyCommand);
        mainForm.setCommandListener(this);
        helloAlert = new Alert("Hello Minka","Selamat Belajar Java Mobile", null,AlertType.INFO);
        helloAlert.setTimeout(Alert.FOREVER);
        helloAlert.addCommand(backCommand);
        helloAlert.setCommandListener(this);
    }
    public void startApp() {
        if (display==null){
            display = Display.getDisplay(this);
        }
        display.setCurrent(mainForm);
    }
    public void pauseApp() {
    }
    public void destroyApp(boolean unconditional) {
    }
    public void commandAction(Command c, Displayable d){
        if (c == exitCommand){
            destroyApp(true);
            notifyDestroyed(); // Exit
        }
        if (c == whyCommand){
            display.setCurrent(helloAlert,d);
        }
    }
}

Output Program

Picture 1

Picture 2

Picture 3





Tidak ada komentar:

Posting Komentar

MENGENAL WAREHOUSE ASSITANT

WAREHOUSE ASSITANT Warehouse Assistant, atau Asisten Gudang, adalah individu atau anggota team yang memiliki peran vital dalam bertanggung ...