Password field !
I have tried too many things to solve it without any results :
comparing a password field ..
Well I know that for example in a JTextField :
JTextField.getText() //not preferable but it returns a string and this is the good side.
But I have tried both of those : (on runtime i fill the password field with "123")
> jLabel1.setText(jTextField1.getText()); //print the "123"
> if(jTextField1.getText() == "123") //FALSE !!
Of course I have tried to put it in a string, and to be sure that the 123 are only '123' without any thing else !
Now I used also to check the getpassword method like that :
char pass = jTextField1.getPassword();
and I have tried every thing ! .. char contains 1 , char -> 2 , char -> 3 ... but they r never equals to their values , and when putting them in a string and makinf the if(str=="123") the result is false forever ..
I don't know what is the mistake in this .. it printes them correctly, output them and all , but they r not equal to their equivalent values so what ?
Thanks for answer .
dont use == when comparing string. use the .equals(String str) method
== will compare the Strings memory addresses, not their values.
Last edited by Phaelax; 01-31-2007 at 08:09 PM.
Thank you anubis and Phalex , it works but if it compares memory adresses how it works with every thing else exept the strings objects ?
ah u meant "String" I see , so the string only can't compare this .
By nbcomer in forum Careers
Last Post: 06-08-2006, 02:30 PM
By Tricia in forum VB Classic
Last Post: 03-30-2002, 01:23 PM
Last Post: 03-12-2001, 10:30 PM
By Georgiana Trigg in forum VB Classic
Last Post: 10-29-2000, 11:21 AM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center