Thursday, December 13, 2012
Membuat telepon menjadi bergetar pada JAVA (J2ME)
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class DemoVibrate extends MIDlet
implements CommandListener {
private Display display;
private Form form;
private Command cmdKeluar, cmdGetar;
public DemoVibrate() {
display = Display.getDisplay(this);
form = new Form("Demo Vibrate");
StringItem isi = new StringItem(null,
"Pilih menu Getar untuk menjadikan " +
"telepon Anda bergetar...",
Item.PLAIN);
form.append(isi);
cmdKeluar = new Command("Keluar", Command.EXIT, 1);
form.addCommand(cmdKeluar);
cmdGetar = new Command("Getar", Command.SCREEN, 1);
form.addCommand(cmdGetar);
form.setCommandListener(this);
}
public void startApp() {
display.setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
if (c == cmdKeluar) {
destroyApp(false);
notifyDestroyed();
} else {
display.vibrate(3000);
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment