Rabu, 26 September 2012

LAB ACTIVITY PEMROGRAMAN J2ME

Percobaan 1 : Hello Midlet


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

public class HelloMidlet extends MIDlet implements CommandListener {
    Display display;
    Command exitCommand = new Command ("Exit", Command.EXIT,1);
    Alert helloAlert;


    public HelloMidlet() {
            helloAlert  = new Alert("Hello MIDlet", "Hello, world!", null, AlertType.INFO);
            helloAlert.setTimeout(Alert.FOREVER);
            helloAlert.addCommand(exitCommand);
            helloAlert.setCommandListener(this);
    }

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

    public void pauseApp() {
    }

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

Hasil Running




Tidak ada komentar:

Posting Komentar