• Post Reply Bookmark Topic Watch Topic
  • New Topic

regarding the JPasswordField

 
narayana satish
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my project i used the control JPasswordField and JTextField.
I can get the text by using getText with JTextField. What method should i use to get the text of JPasswordField.
 
deekasha gunwant
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi narayana,
getPassword() method of JPassword classs can be used for this purpose.
------------------------------
public char[] getPassword()
Returns the text contained in this TextComponent. If the underlying document is null, will give a NullPointerException. For stronger security, it is recommended that the returned character array be cleared after use by setting each character to zero.
----------------------------------------------------
regards
deeksha
 
ramdas kamath
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

whatever is typed in the JpasswordField is stored in a character array. You may convert it into a String and store it in a String variable.
Use String p = String.copyValueOf(password.getPassword());
where password is the name of the JPasswordField
[This message has been edited by ramdas kamath (edited February 14, 2001).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!