Tugas Navigasi Pemrogramman Java Mobile
Sintaks programm navigasi :
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package MarthinCH.MIDLet;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* @author MA
*/
public class WakwawProject extends MIDlet implements CommandListener{
Display tampilan; //----> Membuat tampilan
Form formHome, formSatu, formDua, formTiga; //----> Membuat form Selamat Datang, formSatu, formDua dan formTiga
Command exitCommand = new Command ("Exit", Command.OK, 1); //----> Membuat perintah Exit
Command homeCommand = new Command ("Home", Command.OK, 1); //----> Membuat perintah Home
Command menuCommand = new Command ("Menu", Command.OK, 1); //----> Membuat perintah Menu
Command halaman1 = new Command ("Halaman 1", Command.OK, 1); //----> Membuat perintah objek 'halaman1'
Command halaman2 = new Command ("Halaman 2", Command.OK, 1); //----> Membuat perintah objek 'halaman2'
Command halaman3 = new Command ("Halaman 3", Command.OK, 1); //----> Membuat perintah objek 'halaman3'
public WakwawProject(){
//Form Selamat datang
formHome = new Form("Ini adalah form Selamat Datang");
formHome.addCommand(exitCommand);
formHome.setCommandListener(this);
formHome.addCommand(halaman1);
formHome.addCommand(halaman2);
formHome.addCommand(halaman3);
//Form pertama
formSatu = new Form("Ini adalah form pertama");
formSatu.addCommand(homeCommand);
formSatu.setCommandListener(this);
formSatu.addCommand(halaman2);
formSatu.addCommand(halaman3);
formSatu.addCommand(exitCommand);
formSatu.setCommandListener(this);
//Form kedua
formDua = new Form("Ini adalah form kedua");
formDua.addCommand(homeCommand);
formDua.setCommandListener(this);
formDua.addCommand(halaman1);
formDua.addCommand(halaman3);
formDua.addCommand(exitCommand);
formDua.setCommandListener(this);
//Form ketiga
formTiga = new Form("Ini adalah form ketiga");
formTiga.addCommand(homeCommand);
formTiga.setCommandListener(this);
formTiga.addCommand(halaman1);
formTiga.addCommand(halaman2);
formTiga.addCommand(exitCommand);
formTiga.setCommandListener(this);
}
public void startApp() {
if (tampilan == null) {
tampilan = Display.getDisplay(this);
tampilan.setCurrent(formHome);
}
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
if (c == exitCommand) {
destroyApp(true);
notifyDestroyed(); // Exit
}
//Perintah menuju ke halaman1
else if(c == halaman1)
{
tampilan.setCurrent(formSatu);
}
//Perintah menuju ke halaman2
else if(c == halaman2)
{
tampilan.setCurrent(formDua);
}
//Perintah menuju ke halaman3
else if(c == halaman3)
{
tampilan.setCurrent(formTiga);
}
//Sintaks untuk membuat perintah kembali ke Home
if(c == homeCommand)
{
tampilan.setCurrent(formHome);
}
}
}