Java JPasswordField

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)


Java JPasswordField

The object of a JPasswordField class is a text component specialized for password entry. It allows the editing of a single line of text. It inherits JTextField class.


JPasswordField class declaration

Let's see the declaration for javax.swing.JPasswordField class.

  1. public class JPasswordField extends JTextField  


Commonly used Constructors:




Constructs a new JPasswordField, with a default document, null starting text string, and 0 column width.

JPasswordField(int columns)

Constructs a new empty JPasswordField with the specified number of columns.

JPasswordField(String text)

Constructs a new JPasswordField initialized with the specified text.

JPasswordField(String text, int columns)

Construct a new JPasswordField initialized with the specified text and columns.


Java JPasswordField Example

Java JPasswordField Example with ActionListener