Pages

Saturday, April 4, 2015

EVENT HANDLER

 Menampilkan list pada menu mobile dengan event Handler
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mobileapplication1;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class Midlet extends MIDlet implements CommandListener {

    Display display;
    Command exitCommand = new Command("Exit", Command.EXIT, 1);
    Command Menu = new Command ("Menu", Command.SCREEN,2);
    Command hal1 = new Command ("hal.1", Command.SCREEN,3);
    Command hal2 = new Command ("hal.2", Command.SCREEN,4);
    Command hal3 = new Command ("hal.3", Command.SCREEN,5);
    Alert helloAlert;
    Alert page1;

    public Midlet() {
        helloAlert = new Alert("Selamat datang dipoliteknik negeri medan", "Welcome", null, AlertType.INFO);
        helloAlert.setTimeout(Alert.FOREVER);
        helloAlert.addCommand(exitCommand);
        helloAlert.addCommand(Menu);
        helloAlert.addCommand(hal1);
        helloAlert.addCommand(hal2);
        helloAlert.addCommand(hal3);
        helloAlert.setCommandListener(this);
       
        page1 = new Alert ("ini halaman 1", "page 1", null, AlertType.INFO);
        page1.setTimeout(Alert.FOREVER);
        page1.addCommand(exitCommand);
        page1.setCommandListener(this);
    }

    public void startApp() {
        if (display == null) {
            display = Display.getDisplay(this);
        }
        display.setCurrent(helloAlert);
       
        //if (Menu == hal1){
         //   display = Display.getDisplay(this);
      //  }
        //display.setCurrent(page1);
       
    }
       

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
        if (c == exitCommand) {
            destroyApp(true);
            notifyDestroyed(); // Exit
        }
    }
}

0 comments:

Post a Comment