The Artima Developer Community
Sponsored Link

Java Answers Forum
JPasswordField in java

3 replies on 1 page. Most recent reply: Sep 26, 2004 1:52 AM by Yogesh

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 3 replies on 1 page
sangeetha

Posts: 1
Nickname: sangi
Registered: Sep, 2004

JPasswordField in java Posted: Sep 23, 2004 3:15 AM
Reply to this message Reply
Advertisement
hi
Can anyone say me how to use the JpasswordField bcoz i need an application to check the password and login here is my coding but it has a problem it doesnt work.
CODE :
JPasswordField passwordField=new JPasswordField (25);

if (passwordField!= null)
{
OkButton.addActionListener(new actionListener() {
public void actionPerformed(ActionEvent e) {

char[]input = passwordField.getPassword();
if (isPasswordCorrect(input)) {
JOptionPane.showMessageDialog(controllingFrame,
"Success! You typed the right password.");
} else {
JOptionPane.showMessageDialog(controllingFrame,
"Invalid password. Try again.",
"Error Message",
JOptionPane.ERROR_MESSAGE);
}


}
});


Yogesh

Posts: 19
Nickname: kyogesh
Registered: Sep, 2004

Re: JPasswordField in java Posted: Sep 26, 2004 1:47 AM
Reply to this message Reply
hi
if u want to check whether there is text in passwordfield use if(passwordField.getText()!=null) instead of passwordField!=null.

what ur code does is that passwordField!=null checks whether memory is allocated for passwordfield or not. it doesn't check for the emptyness of passwordfield.
And it is new A[\b]ctionListener() not new a[\b]ctionListener()

bye all the best.

Yogesh

Posts: 19
Nickname: kyogesh
Registered: Sep, 2004

Re: JPasswordField in java Posted: Sep 26, 2004 1:49 AM
Reply to this message Reply
hi
if u want to check whether there is text in passwordfield use if(passwordField.getText()!=null) instead of passwordField!=null.

what ur code does is that passwordField!=null checks whether memory is allocated for passwordfield or not. it doesn't check for the emptyness of passwordfield.
And it is new A[\b]ctionListener() not new a[\b]ctionListener()

bye all the best.

Yogesh

Posts: 19
Nickname: kyogesh
Registered: Sep, 2004

Re: JPasswordField in java Posted: Sep 26, 2004 1:52 AM
Reply to this message Reply
hi
if u want to check whether there is text in passwordfield use if(passwordField.getText()!=null) instead of passwordField!=null.

what ur code does is that passwordField!=null checks whether memory is allocated for passwordfield or not. it doesn't check for the emptyness of passwordfield.
And it is new A[\b]ctionListener() not new a[\b]ctionListener()

bye all the best.

Flat View: This topic has 3 replies on 1 page
Topic: LinkList and sorted Link list Method Previous Topic   Next Topic Topic: How can i connect an applet with a database????

Sponsored Links



Google
  Web Artima.com   

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