J2ME

Share on :
Gan ingin mencoba

ini coding java nya:
Name : Latihan1
Class : Dedi


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

public class FirstList extends MIDlet implements CommandListener{
        Display display;
        List list,lEx,lMu,lIm;
        Image img;
        Command cmExit,cmBack;

        public FirstList(){
            display = Display.getDisplay(this);
            try{
                        img = Image.createImage("/Icon/App.png");
            }catch (java.io.IOException e){
                System.out.println("error gambr: " + e);
            }
            cmBack = new Command("Kembali",Command.BACK,1);
            cmExit = new Command("Keluar",Command.EXIT,1);
            list = new List("First List",List.IMPLICIT);
            list.append("EXCLUSIVE",img);
            list.append("MULTIPLE",img);
            list.append("IMPLICIT",img);
            list.addCommand(cmBack);
            list.addCommand(cmExit);
            list.setCommandListener(this);


              lEx = new List("List EXCLUSIVE",List.EXCLUSIVE);
              lEx.append("string 1",img);
              lEx.append("string 2",img);
              lEx.append("string 3",img);
              lEx.addCommand(cmBack);
              lEx.setCommandListener(this);


              lMu = new List("List MULTIPLE",List.MULTIPLE);
              lMu.append("string 1",img);
              lMu.append("string 2",img);
              lMu.append("string 3",img);
              lMu.addCommand(cmBack);
              lMu.addCommand(cmExit);
              lMu.setCommandListener(this);

              lIm = new List("List IMPLICIT",List.IMPLICIT);
              lIm.append("string 1",img);
              lIm.append("string 2",img);
              lIm.append("string 3",img);
              lIm.addCommand(cmBack);
              lIm.addCommand(cmExit);
              lIm.setCommandListener(this);

        }
    public void startApp() {
        display.setCurrent(list);
    }
    
    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional){
    }
    
    public void commandAction(Command c, Displayable s){
        if(c == List.SELECT_COMMAND) {
                switch (list.getSelectedIndex()) {
                case 0:
                        display.setCurrent(lEx);
                        break ;
                case 1:
                        display.setCurrent(lMu);
                        break;

                case 2:
                        display.setCurrent(lMu);
                }

        }else if(c == cmBack){
                display.setCurrent(list);
        }else if(c == cmExit){
                   exitMIDlet();

            }
       }
        public void exitMIDlet(){
            destroyApp(false);
            notifyDestroyed();
        }
}
selesai 
langkah selanjutnya
buka Weireless toolkit
pilih settings, Required, MIDlet-Name ganti dengan nama Latihan 1
untuk mendukung aplikasi dalam hp bentuk Jar
kemudian pilih Project 
Package > createpackage
selesai dehhh
copy-paste in aja ke hp kamu..
selamat mencoba....

0 komentar on J2ME :

Post a Comment and Don't Spam!

Dedi Maryanto. Diberdayakan oleh Blogger.
My Ping in TotalPing.com