Jumat, 06 April 2012

Membuat Menu Sederhana

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


public class file_menu extends MIDlet implements CommandListener  {
    Alert a;
    Display d;
    Ticker t;
    Command keluar,M1,M2;
    private Command x;
    public file_menu(){
        a=new Alert("Menu Utama",null,null,null);
        t=new Ticker("Hello");
        keluar=new Command("keluar",Command.EXIT,0);
        M1=new Command("profil",Command.OK,0);
        M2=new Command("Visi dan Misi",Command.OK,1);
        a.setTicker(t);
        a.addCommand(keluar);
        a.addCommand(M1);
        a.addCommand(M2);
        a.setTimeout(Alert.FOREVER);
        a.setCommandListener(this);
       
    }
   
    public void startApp() {
    d=Display.getDisplay(this);
    d.setCurrent(a);
   
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command x, Displayable arg1) {
        if(x==keluar){
            destroyApp(true);
            notifyDestroy();
        }
           
        }

    private void notifyDestroy() {
        throw new UnsupportedOperationException("Not yet implemented");
    }
    }

Tidak ada komentar:

Posting Komentar