Aplikasi Login dengan J2ME


He He He Udah lama g nulis lagi, maklum lagi sibuk (waduh kayak pejabat ae) 🙂 . ah udah ah g usah lama lama langsung ae.

sebenere q juga baru belajar bahasa java maklum karena terpaksa sih ngerjain TA.

untuk kali nie q pengen buat aplikasi Java Mobile untuk pengecekan password.

nah sintak nya kayak gini >>>>>>

**
* @author gemix@wordpress.com
*/
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
public class login extends MIDlet implements CommandListener {
private Display display;
private TextField userName;
private TextField password;
private Form form;
private Command cancel;
private Command login;
public login() {
userName = new TextField("LoginID  :", "", 10, TextField.ANY);
password = new TextField("Password :", "", 10, TextField.PASSWORD);
form = new Form("Login");
cancel = new Command("Cancel", Command.CANCEL, 2);
login = new Command("Login", Command.OK, 2);
}
public void startApp() {
form.setTitle("Silakan Login");
form.append(userName);
form.append(password);
form.addCommand(cancel);
form.addCommand(login);
form.setCommandListener(this);
display.setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
notifyDestroyed();
}
public void validateUser(String name, String password) {
if (name.equals("usernya") && password.equals("passwordnya")) {
bener();
} else {
tryAgain();
}
}
public void bener() {
Alert benar = new Alert("Login Sukses", "Selamat Login Sukses", null, AlertType.ERROR);
error.setTimeout(Alert.FOREVER);
display.setCurrent(error);
}
public void tryAgain() {
Alert salah = new Alert("Login salah", "Silakan Ulangi lagi", null, AlertType.ERROR);
salah.setTimeout(Alert.FOREVER);
userName.setString("");
password.setString("");
display.setCurrent(salah, form);
}
public void commandAction(Command c, Displayable d) {
String label = c.getLabel();
if(label.equals("Cancel")) {
destroyApp(true);
} else if(label.equals("Login")) {
validateUser(userName.getString(), password.getString());
}
}
}

2 pemikiran pada “Aplikasi Login dengan J2ME

  1. Selamat buat kelulusannya ya bro………..
    (btw kalau udah meja hijau udah lulus belum ya?)

    Eits… kalau udah wisuda nanti jangan sampai lupa sama KOELIT ya….
    Sering2 jenguk kita2 ke Unijoyo, key brother………

    Bravo PENGUIN!!

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google

You are commenting using your Google account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s