08.24
0
pertama-tama kita membuat projek dengan nama project1 dan classnya coba
sesudah itu ketik coding dibawa ini ke dalama notpade dan save di C:\Users\(nama PC kamu)\j2mewtk\2.5.2\apps\project1\src simpam file tadi dengan nama coba.java.


import java.io.IOException;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;



public class cobai extends MIDlet implements CommandListener
{
Command keluar = new Command ("Keluar",Command.EXIT,1);
Command daftar = new Command ("daftar", Command.OK,2);
Command proses = new Command ("Proses",Command.OK,2);
Command kembali = new Command ("Kembali",Command.BACK,0);
Command startApp = new Command ("awal", Command.OK,1);
Command kembali1 = new Command ("back",Command.BACK,0);

Form f, h;
TextField tf, th, pass, tu;
private Image gbr;
private ChoiceGroup jk;

public coba(){
}
public void startApp()
{
Ticker t = new Ticker ("www.ikbal02.co.cc");
try {
gbr = Image.createImage("/ikbal.jpg");
}
catch (Exception e)
{
}


f = new Form( "ikbal hambali husnnul khuluk" );
f.append( "selamat datang" );
f.append(gbr);
f.setTicker(t);
f.addCommand(keluar);
f.addCommand(daftar);
f.setCommandListener(this);
Display.getDisplay(this).setCurrent(f);

}


public void pauseApp()
{
}

public void destroyApp( boolean unconditional )
{
}

public void awal()
{
Display.getDisplay(this).setCurrent(f);
}
public void keluar()
{
notifyDestroyed();
}

public void daftar()
{
tf = new TextField ("Nama Anda :","", 20,
TextField.ANY);
th = new TextField ("Email : ", "", 20,
TextField.ANY);
pass = new TextField ("Password", "" , 20,
TextField.PASSWORD);
jk = new ChoiceGroup ("Jenis Kelamin : ", Choice.EXCLUSIVE);
jk.append("Laki-Laki", null);
jk.append("Perempuan", null);
tu = new TextField ("Umur :", "", 20,
TextField.ANY);
h = new Form( "Form Login" );
h.append(tf);
h.append(th);
h.append(pass);
h.append(jk);
h.append(tu);

h.addCommand(kembali);
h.addCommand(proses);

h.setCommandListener(this);
Display.getDisplay(this).setCurrent(h);
}
public void proses()
{
String dtproses = tf.getString();
String dt1proses = th.getString();
String dt2proses = pass.getString();
String dt3proses = tu.getString();
Form pf = new Form ("Proses Data");
pf.append ("Nama anda : ");
pf.append (dtproses);
pf.append ("\n");
pf.append ("Email : ");
pf.append (dt1proses);
pf.append ("\n");
pf.append ("Password :");
pf.append (dt2proses);
pf.append ("\n");
pf.append ("Jenis Kelamin :");
if(jk.isSelected(0))
pf.append(jk.getString(0));
else if(jk.isSelected(1))
pf.append(jk.getString(1));
pf.append ("\n");
pf.append ("Umur :");
pf.append (dt3proses);

pf.addCommand (kembali1);
pf.addCommand(startApp);
pf.setCommandListener(this);
Display.getDisplay(this).setCurrent( pf );
}
public void commandAction (Command c, Displayable d)
{
if (c == keluar)
{
keluar();
}
else if (c == daftar)
{
daftar();
}
else if (c == proses)
{
proses();
}
else if (c == kembali)
{
awal();
}
else if (c == startApp)
{
startApp();
}
else if (c == kembali1)
{
daftar();
}

}
}

ganti tulisan yang merah dengan nama foto kamu fotonya disimpan di C:\Users\buluqs\j2mewtk\2.5.2\apps\project1\res

selamat mencoba

0 komentar:

Posting Komentar