The Artima Developer Community
Sponsored Link

Java Answers Forum
how do you verify a password?

2 replies on 1 page. Most recent reply: Mar 22, 2002 1:26 PM by Mary

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Mary

Posts: 7
Nickname: dj
Registered: Mar, 2002

how do you verify a password? Posted: Mar 22, 2002 8:35 AM
Reply to this message Reply
Advertisement
we have created a login screen, and we only want to give access to 1 person called"tange".

this code isn't working, whats wrong??

If(e.getSource()==loginBtn)
{
String s = nameTxt.getText();
if( s - "tange"){
JOptionPane.showMessageDialog(null, "Welcome" +nameTxt.getText());
}


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: how do you verify a password? Posted: Mar 22, 2002 12:23 PM
Reply to this message Reply
Looks like you are only verifying the user name, not the password.

You've got a few problems here:
- Why do you need to do "e.getSource()==loginBtn"? Why not just add an ActionListenter to the button? Then there will be no ambiguity about the source of the action. You may also want to have an action associated with the password entry (or make the button default) so someone can enter a user name and password and hit the enter key.
- You get the name String as s, but then later you are using nameTxt.getText(). I would consistently use one or the other, so as to avoid confusing things.
- It appears that you really want to allow only the user name (not password) of "tange" -- if that is the case, you need to use s.equals("tange") to see if that was the named entered.

Mary

Posts: 7
Nickname: dj
Registered: Mar, 2002

Matt: WE LOVE YOU Posted: Mar 22, 2002 1:26 PM
Reply to this message Reply
Did i ever tell you , you are my hero.......

Flat View: This topic has 2 replies on 1 page
Topic: ok, desperate for help with compile errors Previous Topic   Next Topic Topic: Java question

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use