Password field dont work!
I really got a problem here. The password field dont seem to work!:frusty:
The current script is:
Quote:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
if ((jPasswordField1.getText()) = "Hello"){
this.setVisible(false);
new Admin().setVisible(true);
}
}
I don't want anything fancy encrypt, i just want it to work!
My IDE shows a error message:
Quote:
unexpected type:
required: variable
found: value
Re: Password field dont work!
First off, = is assignment, == is comparison.
Secondly, don't use == to compare Strings. Use the .equals() method instead. The == operator compares whether two variables hold the same reference. The .equals() method compares the actual content of the instances.
Re: Password field dont work!
That shouldn't even compile:
Code:
if (suchAndSuch = "Hello") {
...
}
Also, I thought that getText() was deprecated for JPasswordField.
You will want to change "Hello" into a char array and compare the arrays, which I think you'll need to do element by element. Either that convert the char array held by the JPasswordField obtained via getPassword() into a String via new String(myCharArray), but I don't recommend the latter as it's not as secure. And if you do this, you'll need to compare the two Strings with equals(...), not with ==.
Re: Password field dont work!
Also, are you going to reply to us? You didn't reply to any of the folks who helped you in your last thread. We don't get paid so your replies help "pay" us.
Re: Password field dont work!
At last time my network was down some days, couldn't do anything and totally forgot.
Sorry for that. Right now i am testing the different ways.
Re: Password field dont work!