×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    5

    why does this simple code doesn't work

    Code:
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    import javax.microedition.lcdui.*;
    
    
    public class first extends MIDlet implements CommandListener{
    
    	Display display;
    	Form loginform = new Form("Login Apps");
    	private Command login_command = new Command("Login",Command.OK,1);
    	private Command exit_command = new Command("Exit",Command.EXIT,2);
    	TextField UserName = new TextField("Enter UserName","",10,TextField.NON_PREDICTIVE);
    	TextField PassWord = new TextField("Enter Password","",10,TextField.NON_PREDICTIVE);
    	StringItem Status = new StringItem("Status","Please Login to see Status");
    	
    	
    	public first() {
    		
    	}
    
    	protected void destroyApp(boolean Exit_type) throws MIDletStateChangeException {
    		
    
    	}
    
    	protected void pauseApp() {
    		
    
    	}
    
    	protected void startApp() throws MIDletStateChangeException {
    				
    		loginform.append(UserName);
    		loginform.append(PassWord);
    		loginform.append(Status);
    		loginform.addCommand(login_command);
    		loginform.addCommand(exit_command);
    		loginform.setCommandListener(this);
    		
    		display = Display.getDisplay(this);
    		display.setCurrent(loginform);
    	}
    	
    	
    	public void commandAction(Command cmd, Displayable arg1) {
    		if(cmd==login_command)
    		{
    			String login = UserName.getString();
    			String pass = PassWord.getString();
    			if(login=="java" && pass=="midp")
    				Status.setText("Login Sucess!!!!");
    			else Status.setText("Login Failed!.Try Again!");
    			UserName.setString("");
    			PassWord.setString("");
    		}
    		else if(cmd==exit_command) notifyDestroyed();
    		
    	}
    
    }
    now when i enter username as "java" & password as "midp" it still shows me login failed.whats the problem?

    Thanks for helping!

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,553

    Re: why does this simple code doesn't work

    What does your Java language reference say of the String.equals() method?

  3. #3
    Registered User
    Join Date
    Feb 2011
    Posts
    35

    Re: why does this simple code doesn't work

    Hello wenn32, good evening.

    How about this --> if(login.equals("java") && pass.equals("midp")

Similar Threads

  1. why this simple program doesn't run?
    By Hesam in forum [Archived] Qt SDKs and Tools
    Replies: 1
    Last Post: 2010-04-24, 22:10
  2. why doesn't Display.getDisplay(this).vibrate(milis) work on E65?
    By ronikoren in forum Mobile Java General
    Replies: 3
    Last Post: 2008-08-19, 10:36
  3. why doesn't this gps code work?
    By nick_santa83 in forum Symbian
    Replies: 0
    Last Post: 2007-12-09, 19:03
  4. Why doesn't this GetContact call work!
    By acomber in forum PC Suite API and PC Connectivity SDK
    Replies: 3
    Last Post: 2007-10-08, 22:41
  5. Why does this app not work?
    By jensesaat in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 3
    Last Post: 2006-06-05, 21:30

Posting Permissions

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