hi guys, JPasswordField userPassword=new JPasswordField(10); userPassword="pw"; String test=userPassword.getText().trim(); i am using the above statements and while compiling it displays the following warning. Note: pro.java uses or overrides a deprecated API. Note: Recompile with -deprecation for details. and if i recompile with -deprecation it displays the following warning. pro.java:597: warning: getText() in javax.swing.JPasswordField has been deprecated
String test=userPassword.getText().trim(); ^ please tell me how to remove this warning !!! Thanx vikas
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
posted
0
??? How can this possibly compile at all? On the second line, you're attempting to assign a String to a JPasswordField. Surely the compiler will report that error before informing you of deprecated methods. As for the latter, it's a simple matter to consult the API for inormation about the deprecated method, and a suggestion about what to replace it with. Always consult the API.
"I'm not back." - Bill Harding, Twister
Michael Hildner
Ranch Hand
Joined: Oct 13, 2000
Posts: 297
posted
0
You can use: String myString = new String(passwordField.getPassword()); since that return an array of chars.