You Are Here:

Community: Developer Discussion Boards

#1 Old image creation in j2me - 2009-03-09, 11:59

Join Date: Jan 2009
Posts: 5
pushgod
Offline
Registered User
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());
}
}
}
Reply With Quote

#2 Old Re: image creation in j2me - 2009-03-09, 12:14

Join Date: Apr 2007
Posts: 1,757
Tiger79's Avatar
Tiger79
Online
Forum Nokia Champion
try not to double-post please...
http://discussion.forum.nokia.com/fo...d.php?t=161225
Reply With Quote

#3 Old Re: image creation in j2me - 2009-03-09, 12:28

Join Date: Jun 2003
Posts: 4,325
Location: Cheshire, UK
grahamhughes's Avatar
grahamhughes
Offline
Forum Nokia Champion
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. :)
Reply With Quote

#4 Old Re: image creation in j2me - 2009-03-09, 13:45

Join Date: Jun 2007
Posts: 534
Location: Mumbai
Send a message via Yahoo to prakash.raman
prakash.raman's Avatar
prakash.raman
Offline
Super Contributor
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
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
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

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ