Comment

navin
rey,
October 11, 2008 at 11:36 AM

Creating Midlet Application For Login in J2ME


This example show to create the Midlet application for user login . All Midlet applications for the MIDP ( Mobile Information Device Profile) derived from Midlet class and it play a role as a mediator between the application and the environment in which the application runs. The Midlet life cycle manage the flow of application. It is in the javax.microedition.midlet package, so import this package in your application. The javax.microedition.icdui package is used for following classes:

Alert
AlertType
Canvas
ChoiceGroup
Command
DateField
Display
Displayable
Font
Form
Gauge
Graphics
Image
ImageItem
Item
List
Screen
StringItem
TextBox
TextField
Ticker
In this example we will create a Midlet (LoginExample), that will show following output display look like below:





Click on 'Launch' Button then the login page display like below:



Give Your LoginID 'sandeep' and Password 'sandeep' then it call the commandAction where if condition will be executed and it calls a function (validateUser()) which checks whether name and password is equal to 'sandeep' or not if it equal to 'sandeep' then it executed the showMsg() function which show a congratulation message but if name and password is not equal to 'sandeep' then it call tryAgain() function which show the error page like figure below and it return on login page with refresh value.













Source Code Of LoginExample.java

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;
private Command login,cancel;
private Image img, imge, img2;

public LoginExample() {
form = new Form("Sign in");
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("/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("sandeep") && password.equals("sandeep")) {
showMsg();
} 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(success, form);
}

public void tryAgain() {
Alert error = new Alert("Login Incorrect", "Please try again", imge, AlertType.ERROR);
error.setTimeout(900);
error.setImage(imge);
userName.setString("");
password.setString("");
display.setCurrent(error, form);
}

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




View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Blog

Sitemap J2ME Tutorial
Map | Business Software Services India J2ME Tutorial Section Java Platform Micro Edition | MIDlet Lifecycle J2ME | jad and properties file in J2ME | J2ME Hello World Program | Creating MIDlet Apps for Login in J2ME 

J2EE

Creating Midlet Application For Login in J2ME
Creating MIDlet Application For Login in J2ME  ... application for user login . All MIDlet applications for the MIDP ( Mobile Information...;    Click on 'Launch' Button then the login page display like below 

Mobile Applications Questions

j2me
j2me  i need more points about j2me 

Java Beginners

j2me
j2me  how to compile and run j2me program at command prompt 

Java Beginners

j2me
j2me  why we extends class MIDlet in j2me application 

Design concepts & design patterns Questions

j2me
j2me  how to use keylistener in j2m 

JSP Servlet Questions

j2me
j2me  I need fifth sem MCA mobile computing lab programs using j2me. i m beginner for j2me and i want to know how to run j2me programs. pls help 

Java Beginners

J2ME handing multiple pages
J2ME handing multiple pages  I have 1 midlet and 1 form. How do i... implements CommandListener { private newUser Login; private Form form; private Display display; private TextField username, pwd; private Command login; private Ticker 

Mobile Applications Questions

J2ME
J2ME PROGRAM TO CONNECT WITH MS-ACCES  HI WRITE A J2ME PROGRAM TO CONNECT WITH MS-ACCESS.(CREATING DATABASE) THANKS 

Design concepts & design patterns Questions

J2ME
J2ME  Hi, what is the source code for Mortgage Calculator in J2ME for Developing Symbian 

Java Magazine Questions

j2ME
j2ME  give a sample example for using key listener in j2ME for developing Symbian 

Development process Questions

j2me
j2me  hi, in j2me does any click events for developing Symbian.? and How to add click event for dynamically generated button in j2me on Symbian OS 

Java Beginners

J2me
J2me  How to run j2me program in Wireless tool kit   Hi Friend, Please visit the following link: J2ME Tutorials Thanks 

Mobile Applications Questions

J2ME
J2ME  Dear Sir, Am beginner of j2me am asking so many times but still now i didn't get a reply for you...I want source code to scan a image and upload to server in j2me also QR Code decoding in j2me thanks and regards 

Mobile Applications Questions

J2ME
J2ME  how to create table using four field in RMS 

Java Beginners

J2ME
J2ME  WHEN WILL repaint() of CustomItem will call automatically 

Development process Questions

j2me
j2me  Hi, how can add image in forms but using lick a button. does not using canvas in j2me for Symbian development 

Development process Questions

j2me
j2me  hi, i'm working emulator in j2me language, for Symbian OS (Nokia) development. then, what are the click events in this for developing the application.? Thank you 

Development process Questions

j2me
j2me  hi, how to use LWUIT in emulator J2me for Symbian OS? and also how to install in emulator, did worked 

Java Server Faces Questions

login
login  login page display an error showing failure to login even when the correct information is entered 

Java Beginners

j2me - Java Beginners
j2me  j2me project guide Expert:shahzad i HAVE START A J2ME PROJECT WITH NO CLEAR IDEA .. ANY ONE GUIDE ME my id is shahzad.aziz1@gmail.com... the sensitive information. The information is protected by login and password, which can 

Java Beginners

j2me
j2me  hey i m doing a project can i create message reader using j2me in nokia phone?? pls give me source code or hint 

Mobile Applications Questions

J2ME
J2ME  hi i am just stared j2me learning. can you please tell me how to put radio button and textFiled at same row 

Java Beginners

j2me
j2me  in j2me i want to know how to acess third form from the second form.... so need a program for example with more thaan three form 

Java Beginners

j2me
j2me  in j2me i want to know how to acess third form from the second form.... so need a program for example with more thaan three form 

Java Beginners

J2ME
J2ME  Hi friends, i have display the bar code image from Mysql database to web page i need to display that image in my J2ME application,how 

Java Beginners

J2ME
J2ME  how to change the color of the selected date using J2ME. i.e. if i press select by taking the cursor on the date ,the color of that digit should change 

Java Interview Questions

J2ME
J2ME  how to use form and canvas is same screen in J2ME   Hi Friend, Please visit the following link: http://www.roseindia.net/j2me/CanvasForm.shtml Thanks 

Java Beginners

J2ME
J2ME  how to accept time in textField using constraints in case of J2ME   Hello Friend, Please visit the following link: http://www.roseindia.net/j2me/date-field.shtml Thanks 

Java Beginners

J2ME
J2ME  Hi sir, i need a source code for simple calculator along with buttons in mobile application 

Java Beginners

J2ME
J2ME  how to get the color of a pixel in J2ME but not in Java... J2ME. I am using Canvas. I needed to know, if there is any method to get... line using J2ME 

Java Beginners

j2me
j2me  COmmand c=new Command("Exit",Command.EXIT,100);Please expalin abt 3 parameters 

Struts Questions

login
login  how to login admin and user with the same fields(name & password) in single login page while the table for admin and user is seprate in database(mysql) please provide me solution 

Development process Questions

J2ME
J2ME  i am working in j2ME language on Symbian OS S60 (Nokia)application in this application i am adding buttons for designing in MIDlet application. so how to add button in dynamically. and how can place lancher icon also 

Java Beginners

J2ME
J2ME -i want to execute j2me program using sun wireless tool kit 2.5.2 pls suggest me which WTK for 64 bit operating system  hello sir, i am using windows 7 64 bit in my laptop...,i want to execute j2me program using sun wireless 

Java Magazine Questions

login
login  i want to now how i can write code for form login incolude user and password in Jcreator 4.50   Hello Friend, Visit Here Thanks 

Mobile Applications Questions

j2me
j2me  i want code in which when we input same data in midlet page ... than on ok button it will show in servlet page.. code that pass information to mobile application page to servlet page 

JSP Servlet Questions

j2me
j2me  i want code in which when we input same data in midlet page ... than on ok button it will show in servlet page.. code that pass information to mobile application page to servlet page 

Development process Questions

j2me
j2me   Hi, In my j2me application I have used canvas to display an image in fullscreen.In the image there are four points( rectangular areas ). Now I have to add events to these points. It looks like that those areas will be used 

Development process Questions

J2ME
J2ME  What is the source code for Mortgage Calculator. using text fields are home price,loan amount,down payments,down payment percent, Annual tax... in J2ME language for Symbian developing. so please help me 

Java Beginners

j2me
j2me  hi i'm a java beginner and i am working in j2me. i am using java wireless tool kit and java sdk. and the problem is that i am not getting the out put in the java sdk. for the source code provided by you. please give me 

Development process Questions

j2me
j2me  Hi, i'm working eclipse j2me for Symbian development. i want a combo box use like a scroll bar type. when we are using combo box to a column it acts as one combobox for all cells in a column but i nedd separate combobox 

Java Beginners

login
java.awt.event.*; class Login { JButton SUBMIT; JLabel label1,label2; final JTextField text1,text2; Login() { final JFrame f=new JFrame("Login Form...(); ResultSet rs=st.executeQuery("select * from login where username='"+value1 

JSP Servlet Questions

login
login  how to create login page in jsp   Here is a jsp code that creates the login page and check whether the user is valid or not. 1...;tr><td></td><td><input type="submit" value="Login"> 

Java Beginners

j2me
j2me  What is JAD file what is necesary of that   Hi Friend, Please visit the following link: JAD File Thanks   Hi Friend, Please visit the following link: JAD File Thanks 

Swing AWT

login
login  i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name 

Swing AWT

login
login  i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name 

Swing AWT

login
login  i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name 

Swing AWT

login
login  i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name 

Mobile Applications Questions

j2me
j2me  Hi,i create a project using lwuit in netbeans 6.9 for motorola MC75 device i want to know how can i connect this application with remote server,should i use servlets.actually i have to send data in xml format and also 

Java Beginners

J2ME
J2ME  i wann source code to find out the difference between two dates.. and i wan in detail.. plz do favour for me..   import java.util.... (ParseException e) { e.printStackTrace(); } } }   i wann j2me code 

Java Beginners

login
 

Java Beginners

j2me project guide - Java Beginners
j2me project guide  i HAVE START A J2ME PROJECT WITH NO CLEAR IDEA .. ANY ONE GUIDE ME my id is shahzad.aziz1@gmail.com replay on my id plz... the sensitive information. The information is protected by login and password 

JDBC Questions

how to connect j2me program with mysql using servlet?
how to connect j2me program with mysql using servlet?  my program of j2me import java.io.*; import java.util.*; import javax.microedition.midlet....", Command.EXIT, 1);; private Command login = new Command("Login 

Java Beginners

j2me application
j2me application  code for mobile tracking system using j2me 

J2ME

J2ME Tutorial
; Creating MIDlet Application For Login in J2ME This example show... J2ME Tutorial       J2ME kxml Java Platform Micro Edition Java ME 

Java Beginners

login page
login page  code for login page 

Java Beginners

j2me QUE
j2me QUE  Iam New for j2me .plz tell me how to compile and run j2me program and what software needed fot 

JMS Questions

j2me program
j2me program  how to run j2me program?what setting is to do whem we run j2me programs?   Please go through the following link: J2ME Tutorials 

Mobile Applications Questions

J2me - MobileApplications
J2me  How to connect JDBC with MIDP 

Mobile Applications Questions

J2ME - MobileApplications
J2ME  How can we create a grid of controls on J2ME with different image present on each control 

Mobile Applications Questions

j2me - MobileApplications
j2me  Hi, How can we get google maps through j2me 

PHP Questions

login-logout
login-logout  how to do login and logout using session in php 

PHP Questions

login page
login page  How to login as different user in php 

HTML Questions

Login page
Login page  how to create Login page in java 

PHP Questions

LOGIN ERROR
LOGIN ERROR  ERROR SCRIPT: LOGIN FAILED", $_SESSION['login fail']='0',}?> Ty Team 

Swing AWT

Login authentication
Login authentication  i want d code for login authentication from mysql database on the same pc using swings 

Swing AWT

Login authentication
Login authentication  i want d code for login authentication from mysql database on the same pc using swings 

JSP Servlet Questions

Login Page
Login Page  Can anyone tell me the steps to create a login page in myeclipse 7.0 and validating it with login database in db2 9.7 ??? Please tell me 

Development process Questions

j2me beginner
j2me beginner  how to create an application for sending files via bluetooth please i want full codings 

Development process Questions

j2me and blutooth
j2me and blutooth  how to pass canvas object between two devices using blutooth 

Java Beginners

LOGIN PAGE
LOGIN PAGE  A java program with "login" as title,menus added, and a text field asking for firstname, lastname, and displaying current date and time 

JSP Servlet Questions

login application
login application  how to create login application ?   Hi, Please check the following tutorials: Video tutorial - JSP Login Logout Example Login Authentication using Bean and Servlet In JSP simple code to login user 

Struts Questions

Login Program
Login Program  Login program in struts to set username & password in session. and this session is available in all screens for authentication..., Please read it at: Login/Logout With Session Accessing Session Object Thanks 

Mobile Applications Questions

j2me question
j2me question  write a j2me program that accepts two integer values from the user through a form and display the result of multiplication on a new screen.   Please visit the following link: http://www.roseindia.net 

JSP Servlet Questions

Login modification
Login modification  How can I invalidate a user once he goes back to login page without signing out,I have already tried using session but it doesn't work please help 

Mobile Applications Questions

J2me - MobileApplications
J2me  Hi, I would like to know how to send orders linux to a servlet which renvoit answers to a midlet. thank you 

Mobile Applications Questions

J2ME - MobileApplications
J2ME  Have to develop a tracking system as a project have to track... year project can anyone tell me is it ok? If not then suggest some another J2ME... link: http://www.roseindia.net/j2me/ Hope that it will be helpful for you 

Mobile Applications Questions

J2ME - MobileApplications
J2ME  Hi I want to know how I can downlload J2ME programming and if ypu have any idea about it please help me. Thank  Hi Friend, Please visit the following links: http://www.roseindia.net/j2me/ http 

Mobile Applications Questions

j2me exception - MobileApplications
j2me exception  Hai 

Java Beginners

login box
login box  class file for password and conform password and how it connected to database 

IDE Questions

login page
login page  pls say how to create a login page in jsp and mysql using netbaens   Hi Friend, Please visit the following links: http://roseindia.net/jsf/netbeans/index.shtml http://roseindia.net/jsp/loginbean.shtml 

Mobile Applications Questions

j2me - MobileApplications
j2me  how can I send sms and audio from my computer to other cell phones including blue tooth? providing any good url/information/book names will highly be appriciated 

Mobile Applications Questions

j2me - MobileApplications
j2me  how can I send sms and audio/video from computer to cell phones. Program is not required only logic and some useful url/books/information is required. Thanks 

Mobile Applications Questions

j2me - MobileApplications
j2me  Hi, I have developed a midlet application in j2me now i want..., For more information on J2me visit to : http://www.roseindia.net/j2me/java-platform-micro-edition.shtml http://www.roseindia.net/j2me/ Thanks 

Mobile Applications Questions

j2me - MobileApplications
j2me  Dear all... Can you plz tell what is the distribution based security of mobile application,wat should be criteria for stoping the illegal copieng of software. Thanks Regards Rashan Abid 

SQL Question

login data
login data  Hiiii Sir I am doing banking project on Asp.net i have... the data after login i want to show particular data for particular user means if i login i wanna see only myn data how shud i do thanxx in advance 

SQL Question

login data
login data   Hiiii Sir I am doing banking project on Asp.net i have... the data after login i want to show particular data for particular user means if i login i wanna see only myn data how shud i do thanxx in advance 

Java Beginners

J2ME question
J2ME question  Lets say i have 2 screens. One for new user, another for existing user. Currently, the midlet contains radio boxes that allows users... the user chooses "new user". IM stuck at if command part   J2ME Tutorials 

Java3D Questions

J2ME - Java3D
J2ME  I want to move a rectangle in J2ME so i want the code   Hi Friend, Please visit the following link. This link has the similar example of moving image. You can also move rectangle by using repaint(). http 

JDBC Questions

Login Form
Login Form  I have 8 jsp pages.Each of them has three columns:Left... of +,on clicking which a login form appears. Only the middle column is different for each of the page. How to write a code for login authentication so 

JDBC Questions

Login Form
Login Form  I have 8 jsp pages.Each of them has three columns:Left... of +,on clicking which a login form appears. Only the middle column is different for each of the page. How to write a code for login authentication so 

Mobile Applications Questions

J2ME - MobileApplications
J2ME  Hi, I wanted to ask that if i want to add Select Language option in my mobile application, can i do that and if yes how? Also if its possible then will my text change in to the language i have selected or i have to write 

Mobile Applications Questions

j2me - MobileApplications
j2me  Hey.... I am developing a mobile application which stores the important datas, can you plz suggest how to take back up of datas in phone gallery which I am storing in rms, Thanks and regards Rashan Abid 9990978757 

Mobile Applications Questions

j2me mobile list - MobileApplications
j2me mobile list  on which mobiles the j2me applications are compatible to run 

Java Beginners

J2ME - Java Beginners
J2ME  I want know about J2ME with coding examples 

Java Beginners

AES encryption in J2ME
AES encryption in J2ME  Is it possible to do aes encryption in j2me 

Java Beginners

JSP LOGIN
JSP LOGIN  sir....i have two user types usercategory and user and both user have userid and password in two different table and now i am making login page for which i have to retrieve usertype,userid and password from two 

Java Magazine Questions

j2me pgrm run
j2me pgrm run  How to run a j2me program   Please visit the following link: J2ME Tutorials 

JSP Servlet Questions

login page
login page  hi i'm trying to create login page using jsp. i get... <h1>Login Example!</h1> USER NAME <input name="uname...="text"/><br> <br> <input name="Login" type="submit" value 

Advertisements Advertisements
 

 

 

DMCA.com