Membuat MIDlet Dengan Menggunakan NetBeans Mobility Pack (Emulator)
Seperti program-program sebelumnya, yang diperlukan dalam membuat program ini adalah NetBeans dan NetBeans Mobility Pack yang harus sudah terinstall di komputer Anda.
Langkah - Langkah Membuat MIDlet sederhana :
- Membuat project baru
- Memilih kategori “Mobile
- Memilih “Mobile Application
- Beri nama project dan tentukan lokasinya (Hilangkan tanda pada “Create Hello MIDlet”, dan ketikan "Hello World")
- Memilih Platform (optional)
- Membuat sebuah MIDlet barLangkah 7: Memilih MIDP “Category” dan MIDlet “File Typ
- Memilih MIDP “Category” dan MIDlet “File
- Memberi nama MIDlet
- Mengganti code yang dibuat secara otomatis dengan code program
import javax.microedition.midlet.*;
/**
* @author jeffrey
*/
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();
}
}
}
10. Mengcompile dan Menjalankan (Run) MIDlet di Emulator kita
11. Menjalankan MIDlet kita di Emulator
Tampilan pada Emulator
No comments:
Post a Comment