0

Can anyone guide me is there password masking in java(eclipse) if there is any possibility then plz share with me

I want to make a program in which a use enter a password and it become staric

16th Jan 2021, 9:01 PM
Sohail Mughal
Sohail Mughal - avatar
7 Answers
+ 2
It sounds like you're making a graphical user interface using Java's AWT or swing packages and want a text input component that hides the characters from someone looking over your shoulder. It sounds like you want the Java swing equivalent to <input type="password">. You want to use JPasswordField. The class is documented here: https://docs.oracle.com/javase/7/docs/api/javax/swing/JPasswordField.html How to use it with examples is explained here: https://docs.oracle.com/javase/tutorial/uiswing/components/passwordfield.html
17th Jan 2021, 5:19 AM
Josh Greig
Josh Greig - avatar
+ 2
Run this on your PC. Both username and password is kept as admin. https://code.sololearn.com/cA10a4a10A10/?ref=app
18th Jan 2021, 1:26 PM
Avinesh
Avinesh - avatar
+ 1
Just in case if it's a basic command line application, then you can use the "readPassword()" from the "Console" class. But this will not turn the password to * and will only hide it so that it's not displayed.
17th Jan 2021, 12:49 PM
Avinesh
Avinesh - avatar
+ 1
Use Avinesh's answers then. Here is a page with examples too: https://www.javatpoint.com/java-console-readpassword-method Hopefully you get better at using google to search for things like that soon because it'll speed you up lots more than asking and waiting for answers from people like us. You'll find lots of information by searching "java Console readPassword".
18th Jan 2021, 8:49 PM
Josh Greig
Josh Greig - avatar
0
Avinesh bro thanks for your valuable comment, but i am not able to make full code of it can you share code with me Its himble request
18th Jan 2021, 1:08 PM
Sohail Mughal
Sohail Mughal - avatar
0
Josh Greig no man i am just asking about command line
18th Jan 2021, 1:09 PM
Sohail Mughal
Sohail Mughal - avatar
0
Thank you buddy
19th Jan 2021, 3:20 AM
Sohail Mughal
Sohail Mughal - avatar