Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Swing / AWT / SWT and the fly likes A Warning !?? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "A Warning !??" Watch "A Warning !??" New topic
Author

A Warning !??

vikas de
Ranch Hand

Joined: Feb 07, 2001
Posts: 39
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
??? 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
You can use:
String myString = new String(passwordField.getPassword());
since that return an array of chars.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A Warning !??
 
Similar Threads
Note messages after compiling an APPLET
deprecated API
Doubt in annotations.
one question about the Date Class!
JTable dates