So I\'ve been working on a Password Strength Checker and the way it works is that the user enters some random text into a textfield and then instantaneous visual feedback (break
How exactly do I mask the user input with asterisks preserving its original value?
Use the JPasswordField
which has nice function jPasswordField.getPassword();
to get the password as char[]
to work with.
jPasswordField1.setEchoChar('*')
to mask the password characters with *
. jPasswordField1.setEchoChar((char)0);
Setting a value of 0
indicates that you wish to see the text as it is typed, similar to the behavior of a standard JTextField
.Tutorial and Reference: