Filename | Membuat menu di java |
Permission | rw-r--r-- |
Author | Artikel |
Date and Time | 06.23 |
Label | java |
Action |
Alat nya
- NetBean 6
- JDK 7
karena pada versi 7 tidak ada mobilitynya, sementara kita mau buat aplikasi handphone berbasis java..
ok mari kita mulai
buat project baru
setelah selesai
buat file baru
OK saya anggap dh siap
sekarang kita masuk ke coding nya
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class membuatmenu extends MIDlet implements CommandListener{
Alert tampil;
Display layar;
Ticker jalan;
Command x,tombol,tombol1,tombol2;
public membuatmenu(){
tampil = new Alert ("Aplikasi Test","Latihan membuat menu",null,AlertType.ALARM);
jalan = new Ticker ("Selamat datang");
tombol = new Command ("Keluar",Command.EXIT,0);
tombol1 = new Command ("Dataku",Command.OK,0);
tombol2 = new Command ("wew kk", Command.OK,1);
tampil.setTicker(jalan);
tampil.addCommand(tombol);
tampil.addCommand(tombol1);
tampil.addCommand(tombol2);
tampil.setCommandListener(this);
}
public void startApp() {
layar=Display.getDisplay(this);
layar.setCurrent(tampil);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command arg0, Displayable arg1) {
if (arg0==tombol){
destroyApp(true);
notifyDestroyed();
}
if (arg0==tombol1){
tampil = new Alert ("Dataku adalah","Nama : robtz
\nkelas : TIP 1011 \n",null,AlertType.WARNING);
x = new Command ("back",Command.OK,0);
tampil.addCommand(x);
tampil.setTimeout(Alert.FOREVER);
tampil.setCommandListener(this);
layar.setCurrent(tampil);
}
if (arg0==x){
tampil = new Alert ("Aplikasi Test","Latihan membuat menu",null,AlertType.ALARM);
jalan = new Ticker ("Selamat datang");
tombol = new Command ("Keluar",Command.EXIT,0);
tombol1 = new Command ("Dataku",Command.OK,0);
tombol2 = new Command ("wew kk", Command.OK,1);
tampil.setTicker(jalan);
tampil.addCommand(tombol);
tampil.addCommand(tombol1);
tampil.addCommand(tombol2);
tampil.setCommandListener(this);
layar.setCurrent(tampil);
}
if (arg0==tombol2){
tampil = new Alert ("Dataku adalah","www.medancyberteam.web.id \n",null,AlertType.WARNING);
tampil.setCommandListener(this);
layar.setCurrent(tampil);
}
}
}