Advertisement
DraKiNs

[PROJETO] Login em J2ME

Nov 27th, 2011
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1. import java.io.*;
  2. import javax.microedition.midlet.*;
  3. import javax.microedition.lcdui.*;
  4.  
  5. public class Midlet extends MIDlet implements CommandListener
  6. {
  7.     private Display display;
  8.     private Form form;
  9.     private Command logar, exit;
  10.     private TextField usuario, senha;
  11.     public Midlet() {
  12.         display = Display.getDisplay(this);
  13.         form = new Form("Efetue seu Login");
  14.  
  15.         logar = new Command("Login", Command.SCREEN, 1);
  16.         exit = new Command("Sair", Command.EXIT, 1);
  17.  
  18.         usuario = new TextField("Login:", "", 30, TextField.ANY);
  19.         senha = new TextField("Senha:", "", 30, TextField.PASSWORD);
  20.  
  21.         form.addCommand(exit);
  22.         form.addCommand(logar);
  23.  
  24.         form.append(usuario);
  25.         form.append(senha);
  26.  
  27.         form.setCommandListener(this);
  28.     }
  29.  
  30.     public void startApp()
  31.     {
  32.         display.setCurrent(form);
  33.     }
  34.  
  35.     public void pauseApp(){}
  36.  
  37.     public void destroyApp(boolean unconditional)
  38.     {
  39.         notifyDestroyed();
  40.     }
  41.  
  42.     public void commandAction(Command c, Displayable s)
  43.     {
  44.         String label = c.getLabel();
  45.         if (label.equals("Login"))
  46.         {
  47.             if (usuario.getString().equals("ipsBruno") && senha.getString().equals("123"))
  48.             {
  49.                 form.append("Parabens voce foi logado com sucesso!");  
  50.  
  51.             }
  52.             else
  53.             {
  54.                 form.append("Voce errou a senha tente novamente");
  55.             }
  56.         }
  57.         else if (label.equals("Sair"))
  58.         {
  59.             destroyApp(false);
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement