import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class Form1 extends MIDlet implements CommandListener
{
   private Display display;
   private Form f1;
   private Form f2;
   private TextField user;
   private TextField password;
   private Command okCommand;
   private Command exitCommand;

   public Form1()
   {
      display = Display.getDisplay(this);
      f1 = new Form("Login");
      user = new TextField("User", "", 10, TextField.ANY);
      password = new TextField("Password", "", 6, TextField.PASSWORD);

      okCommand = new Command("Ok", Command.OK, 0);
      exitCommand = new Command("Exit", Command.SCREEN, 0);
   }

   public void startApp()
   {
      f1.append(user);
      f1.append(password);

      f1.addCommand(okCommand);
      f1.addCommand(exitCommand);
      f1.setCommandListener(this);
      display.setCurrent(f1);
   }

   public void pauseApp(){}

   public void destroyApp(boolean b){}

   public void commandAction(Command c, Displayable s)
   {
      if(c == okCommand)
      {
         f2 = new Form("Welcome");

         String text = new String();
         text = "Welcome, " + user.getString() + ", your password is wrong";
         f2.append(text);

         f2.addCommand(exitCommand);
         f2.setCommandListener(this);
         display.setCurrent(f2);
      }else if(c == exitCommand)
      {
         destroyApp(false);
         notifyDestroyed();
      }
   }
}


