Category Archives: JPasswordField

Creating a password field in Java



Introduction

JPasswordField is the Swing Password in Java. Just like the other javax.swing Components it’s a JavaBean. Here’s how to implement it:

JPasswordField textfield = new JPasswordField("Initial Text");
textfield.setEchoChar('#');
textfield.addActionListener(actionListener);