doudt in JPasswordField

hai,

i had and doubt to retrieve the content of password field..?

Sample code

JPassword pass = new JPasswordField();

String s= pass.getPassword().toString();

System.out.println("" + s);

the result s is not returing the exacte content of password that had given at the runtime ......

And i m unable to use the getText() since its get Deprecated

And also let me know how to find the length of the jpassword field

my code is

int i=pass.getPassword().toString().length();

result is i returns 10 always

pls give solution for this

Thanx in advance

shanthy

[644 byte] By [shanker_vkra] at [2007-10-2 10:27:39]
# 1

pass.getPassword() returns a char array containing the password.

String s = pass.getPassword().toString(); returns a String representing a pseudo pointer to the char array containing the password and NOT NOT NOT a representation of the content of the array!

Just use the char array as a char array and don't convert to a String.

sabre150a at 2007-7-13 2:08:26 > top of Java-index,Desktop,Core GUI APIs...