Password Masking | Sololearn: Learn to code for FREE!


Password Masking

How do you mask a password in an IDE?...a code example will be appreciated...

6/21/2019 11:49:53 AM


6 Answers

New Answer


final String password, message = "Enter password"; if( System.console() == null ) { // inside IDE like Eclipse or NetBeans final JPasswordField pf = new JPasswordField(); password = JOptionPane.showConfirmDialog( null, pf, message, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE ) == JOptionPane.OK_OPTION ? new String( pf.getPassword() ) : ""; } else password = new String( System.console().readPassword( "%s> ", message ) );



in case your are ever interested in android development its: given "password" is an EditText variable --> password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);


thank you dear,can you help me with the solution for the one without GUI...


In an IDE? Not sure u can mask it.. Maybe on runtime, user might not see it that's when it can get mask but in an IDE? I doubt..


Mind To Machine 💻🕆 you code Android apps?