• Post Reply Bookmark Topic Watch Topic
  • New Topic

JPasswordField convert to String?  RSS feed

 
kelvin cheung
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String pass= passordFelt.getPassword();

i could not cast it to String
String pass= (String) passordFelt.getPassword();



but i need that password to be String,
cause i need it to be sent to

getConnection(url,user,pass) where pass is a String type.


anyone knows?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sun JPasswordField Tutorial.
 
kelvin cheung
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi gregg,

thank you for the link.

but i still dont get it..
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kelvin cheung:
hi gregg,

thank you for the link.

but i still dont get it..


What don't you get? The API states that getPassword() returns a character array. You could then very easily do:

 
kelvin cheung
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi gregg,

i just didnt know this :
String

public String(char[] value)
Allocates a new String so that it represents the sequence of characters currently contained in the character array argument. The contents of the character array are copied; subsequent modification of the character array does not affect the newly created string.




but now i know.

everything is fine now.
it works!

thank you so much gregg!
 
Elvin Ahmadov
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!