Powered By Blogger

Sabtu, 11 April 2015

Tugas Latihan 1 Java Mobile , 11 April 2015

import.javax.microedition.midlet.*;
import.javax.microedition.Lcdui;
public class Latihan1 extends MIDlet implements CommandListener{
Display dis;
Command exitCommand = new Command("Exit", Command.EXIT,1);
Command hal1Command = new Command("Page 1", Command.OK,1);
Command hal2Command = new Command("Page 2", Command.OK,1);
Command hal3Command = new Command("Page 3", Command.OK,1);
Command homeCommand = new Command("Home", Command.OK,1);
Form homeForm  = null;
Form hal1Form = null;
Form hal2Form = null;
Form hal3Form = null;
public Tugas1(){
super();
homeForm=new Form("Selamat Datang Di Politeknik Negeri Medan");
homeForm.addCommand(exitCommand);
homeForm.addCommand(hal1Command); 
homeForm.addCommand(hal2Command); 
homeForm.addCommand(hal3Command);
homeForm.setCommandListener(this);
hal1Form=new Form("Page 1");
hal1Form.addCommand(homeCommand);
hal1Form.addCommand(hal2Command);
hal1Form.addCommand(hal3Command);
hal1Form.addCommand(exitCommand);
hal1Form.setCommandListener(this);
hal2Form=new Form("Page 2");
hal2Form.addCommand(homeCommand);
hal2Form.addCommand(hal1Command);
hal2Form.addCommand(hal3Command);
hal2Form.addCommand(exitCommand);
hal2Form.setCommandListener(this);
hal3Form=new Form("Page 3"); 
hal3Form.addCommand(homeCommand);
hal3Form.addCommand(hal1Command);
hal3Form.addCommand(hal2Command);
hal3Form.addCommand(exitCommand);
hal3Form.setCommandListener(this);
}
public void startApp() {
if (dis==null){
dis=Display.getDisplay(this);
}
dis.setCurrent(homeForm);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}

public void commandAction(Command c, Displayable d){
if(c==exitCommand){
destroyApp(true);
notifyDestroyed(); //Exit
}
else if(c==page1Command){
dis.setCurrent(page1Form);
}
else if(c==page2Command){
dis.setCurrent(page2Form);
}
else if(c==page3Command){
dis.setCurrent(page3Form);
}
else if(c==homeCommand){
dis.setCurrent(homeForm);
}
}
}

Tidak ada komentar:

Posting Komentar