| Reply | « Previous Thread | Next Thread » |
|
Hey im really new 2 j2me n i ws tryin 2 execute dis code of login. But im havin problem wid creation of image. The code 4 login is working but it is nt displayin d imgs . It is giving null pointer exception while creating img. The imges r stored on c drive as mentioned in d path.
Can anyone plz help me??????? 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("c:/pn.png"); imge = Image.createImage("c:/pn.png"); img2 = Image.createImage("c:/pn.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()); } } } |
|
try not to double-post please...
http://discussion.forum.nokia.com/fo...d.php?t=161225 |
|
Also, those of us over the age of 30 would find it much easier to read your posts if you used actual words, rather than writing like u r sendin d txt msg. :)
|
| grahamhughes |
| View Public Profile |
| Find all posts by grahamhughes |
|
Hi,
I think in place of if (name.equals("sandeep") && password.equals("sandeep")) { showMsg(); } u should use if (name.comparsTo("sandeep") && password.comparsTo("sandeep")) { showMsg(); } au revoir Prakash Raman |
| prakash.raman |
| View Public Profile |
| Find all posts by prakash.raman |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| J2ME or C++ for VoIP on Mobile Phone | sandeepkumar03 | Mobile Java Media (Graphics & Sounds) | 2 | 2008-11-13 21:14 |
| how to do image compression in j2me | proj_sumaiya | Mobile Java General | 2 | 2008-02-04 13:46 |
| --- ???save image problem??? --- | ferenn | Mobile Java Media (Graphics & Sounds) | 6 | 2007-10-01 15:33 |
| cature and save image using J2ME? | gr8umm | Mobile Java General | 11 | 2007-04-19 21:48 |
| Image capturing using MMAPI of J2ME in series 60 | adhiyal | Mobile Java Media (Graphics & Sounds) | 1 | 2004-10-01 08:25 |