APLIKASI TextField 2

APLIKASI TextField 2

Diposkan oleh vautsan on Sabtu, 10 Mei 2014



 APLIKASI TextField 2


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

public class LoginExample extends MIDlet implements CommandListener{
  private Display display;
  private TextField userName,password;
  public Form form,Images;
  private Command login,cancel;
  private Image img, imge, img2;

  public LoginExample() {
    form = new Form("Sign in");
    userName = new TextField("LoginID:", "", 30, TextField.NUMERIC);
    password = new TextField("Password:", "", 30, TextField.PASSWORD);
    cancel = new Command("Cancel", Command.CANCEL, 2);
    login = new Command("Login", Command.OK, 2);
    try{
      img = Image.createImage("/logo.png");
      imge = Image.createImage("/front_left1_bad.png");
      img2 = Image.createImage("/Congratulations-1.png");
    }catch(Exception e){
      System.out.println(e.getMessage());
    }
  }
   public void startApp() {
    display = Display.getDisplay(this);
    try{  form.append(img);}catch(Exception e){}
    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("270685") && password.equals("oman")) {
      showMsg();
    } else {
      tryAgain();
    }
  }

  public void showMsg() {
    Alert success = new Alert("Login Successfully",
    "Your Login Process is completed!",
     img2, AlertType.INFO);
    success.setImage(img2);
    userName.getString();
    password.getString();
    display.setCurrent(success, form);
  }

  public void tryAgain() {
    Alert error = new Alert("Login Incorrect"," Please  try again",
    imge, AlertType.ERROR);

    error.setTimeout(900);
    error.setImage(imge);
    userName.getString();
    password.getString();
    display.setCurrent(error, form);
  }

  public void commandAction(Command c, Displayable d) {
    String label = c.getLabel();
    System.out.println(label.toString());
    if(label.equals("Cancel")) {
      destroyApp(true);
    } else if(label.equals("Login")) {
      validateUser(userName.getString(), password.getString());
    }
  }
}


# SIMPAN DENGAN NAMA FILE LoginExample.java




Comments
1 Comments

{ 1 komentar... read them below or add one }

RISKY AKBAR mengatakan...

Pasang iklan kami di blog anda

kunjungi :
http://riskyakbarweb.blogspot.com/2014/04/iklan.html

Posting Komentar

komentar akan ditanggapi dengan ramah klem aza iaa :>

insya alloh saya coment balik brow :)

link download heking

Popular Posts

Pengikut

category