Saturday, September 25, 2010

Creating a simple login page project in J2ME

This tutorial explains how to create a basic login page which includes textfields ,checkbox  as well as alerts and ticker.
A ticker is a class using which we can move the text along the width of the screen.
But before you read this tutorial please go through the previous ones.   (First Tutorial)                   

Click here to view video tutorial online



Click here to download

Source code:-

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

public class LOGIN extends MIDlet implements CommandListener {

    public Form form =new Form("Sign In Here");
    public TextField t1 =new TextField("Username","",10,TextField.ANY);
    public TextField t2 =new TextField("Password","",10,TextField.PASSWORD);
    public Ticker t =new Ticker("Enter username and password to sign in");
    public Command SignIn=new Command("SignIn",Command.OK,1);
    public ChoiceGroup c1 =new ChoiceGroup("",Choice.MULTIPLE);
    public LOGIN()
    {
        c1.append("Remember me", null);
        form.append(t1);
        form.append(t2);
        form.addCommand(SignIn);
        form.setCommandListener(this);
        form.setTicker(t);
        form.append(c1);
    }
   
  public void commandAction(Command c, Displayable d) {
      if(c==SignIn)
      {
          Alert a1 = new Alert("LOGGED IN","You have successfully" +
                  " logged in",null,AlertType.INFO);
          a1.setTimeout(1000);
          Display.getDisplay(this).setCurrent(a1,form);
      }
  }

    public void startApp() {
        Display.getDisplay(this).setCurrent(form);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }
}                                                                                                                  Next Post

No comments:

Post a Comment

customised by Vaibhav