Creating a Password Text Field When the user hits RETURN, the text field fires an action event. JPasswordField textfield = new JPasswordField( "Initial Text"); textfield.setEchoChar('#'); textfield.addActionListener(actionListener);