You are on page 1of 3

import import import import

javax.microedition.lcdui.*; javax.microedition.media.Manager; javax.microedition.media.control.ToneControl; javax.microedition.midlet.*;

/** * @author unknowx */ public class final1 extends MIDlet implements CommandListener{ private Display display; boolean b_started=false; private int xmillis; private List list; private TextField username,password; public Form form,form1; private Command login,cancel; private Image img, imge, img2; public final1(){ form = new Form("Sistema de Almacenes"); form1= new Form(" En construccion..."); username = new TextField("LoginID:", "", 30, TextField.ANY); 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("/login.png"); //imge = Image.createImage("/mal.png"); //img2 = Image.createImage("/bien.png"); }catch(Exception e){ System.out.println(e.getMessage()); } } public void startApp() { if(b_started) { display=null; xmillis=0; } else { display=Display.getDisplay(this); b_started=true; new Thread(new DibujarLogo(display,3000) { public void execute() { 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);

} } ).start(); } } private final List getlismenu() { list=new List("Menu Prinicipal",List.IMPLICIT); list.append("Sistemas a Medida", null); list.append("Acerca de Nosotros", null); list.append("Sistemas",null); list.append("Ventas", null); list.append("Enlaces", null); list.append("Demos",null); list.append("Ayuda",null); list.setSelectCommand(new Command ("Seleccionar",Command.OK,10)); list.addCommand(new Command("Salir",Command.BACK,20)); list.setCommandListener(this); return list; } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void validateUser(String name, String password) { if (username.equals("piter") && password.equals("piter")) { display.setCurrent(getlismenu()); } else { tryAgain(); } } public void showMsg() { /*Alert success = new Alert("Login Successfully", "Your Login Process is completed!", img2, AlertType.INFO); success.setImage(img2); userName.setString(""); password.setString("");*/ display.setCurrent(form1); } public void tryAgain() { Alert error = new Alert("Login Incorrect", "Please try again", imge, AlertTy pe.ERROR); error.setTimeout(900); error.setImage(imge); userName.setString(""); password.setString(""); display.setCurrent(error, form); } public void commandAction(final Command cmd, final Displayable displayable) { xmillis=0; if(cmd.getLabel()=="Salir") { try{ Manager.playTone(ToneControl.C4,3000,80);

} catch(Exception e){} destroyApp(false); notifyDestroyed(); } String label = cmd.getLabel(); if(label.equals("Cancel")) { destroyApp(true); } else if(label.equals("Login")) { form.addCommand(cancel); form.addCommand(login); form.setCommandListener(this); validateUser(username.getString(), password.getString()); //display.setCurr ent(form1); } //throw new UnsupportedOperationException("Not supported yet."); } }

You might also like