Jumat, 28 Oktober 2011

j2me - script menampilkan "hello world!"

0 komentar
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(); //Exit
}
}
}

0 komentar:

Posting Komentar