Simulasi Web Browser dengan 4 Form Menggunakan Netbeans 7.3.1
package Irma Azwanty Dalimunthe;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
public class WebBrowser
extends MIDlet
implements CommandListener {
Display disp;
private Command exitCommand;
private Command page1;
private Command page2;
private Command page3;
private Command home;
public void startApp() {
Form formHome = new Form("Home");
formHome.append ("Selamat Datang Di Polmed");
exitCommand = new Command ("Exit", Command.EXIT, 1);
page1 = new Command ("Page 1", Command.SCREEN, 1);
page2 = new Command ("Page 2", Command.SCREEN, 1);
page3 = new Command ("Page 3", Command.SCREEN, 1);
formHome.addCommand(exitCommand);
formHome.addCommand(page1);
formHome.addCommand(page2);
formHome.addCommand(page3);
formHome.setCommandListener(this);
Display.getDisplay(this).setCurrent(formHome);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
if (c == exitCommand) {
destroyApp(true);
notifyDestroyed();
} else if (c == page1) {
Form formPage1 = new Form("Page 1");
formPage1.append ("Ini page 1");
home = new Command ("Home", Command.SCREEN,1);
page2 = new Command ("Page 2", Command.SCREEN, 1);
page3 = new Command ("Page 3", Command.SCREEN, 1);
exitCommand = new Command ("Exit", Command.EXIT, 1);
formPage1.addCommand(home);
formPage1.addCommand(page2);
formPage1.addCommand(page3);
formPage1.addCommand(exitCommand);
formPage1.setCommandListener(this);
Display.getDisplay(this).setCurrent(formPage1);
}
else if (c == page2) {
Form formPage2 = new Form("Page 2");
formPage2.append ("Ini page 2");
home = new Command ("Home", Command.SCREEN, 1);
page1 = new Command ("Page 1", Command.SCREEN, 1);
page3 = new Command ("Page 3", Command.SCREEN, 1);
exitCommand = new Command ("Exit", Command.EXIT, 1);
formPage2.addCommand(home);
formPage2.addCommand(page1);
formPage2.addCommand(page3);
formPage2.addCommand(exitCommand);
formPage2.setCommandListener(this);
Display.getDisplay(this).setCurrent(formPage2);
}
else if (c == page3){
Form formPage3 = new Form("Page 3");
formPage3.append ("Ini page 3");
home = new Command ("Home", Command.SCREEN, 1);
page1 = new Command ("Page 1", Command.SCREEN, 1);
page2 = new Command ("Page 2", Command.SCREEN, 1);
exitCommand = new Command ("Exit", Command.EXIT, 1);
formPage3.addCommand(home);
formPage3.addCommand(page1);
formPage3.addCommand(page2);
formPage3.addCommand(exitCommand);
formPage3.setCommandListener(this);
Display.getDisplay(this).setCurrent(formPage3);
}
else if (c == home){
Form formHome = new Form("Home");
formHome.append ("Selamat Datang Di Polmed");
exitCommand = new Command ("Exit", Command.EXIT, 1);
page1 = new Command ("Page 1", Command.SCREEN, 1);
page2 = new Command ("Page 2", Command.SCREEN, 1);
page3 = new Command ("Page 3", Command.SCREEN, 1);
formHome.addCommand(exitCommand);
formHome.addCommand(page1);
formHome.addCommand(page2);
formHome.addCommand(page3);
formHome.setCommandListener(this);
Display.getDisplay(this).setCurrent(formHome);
}
}
}
Tidak ada komentar:
Posting Komentar