new JPasswordField(String text, int columns) : JPasswordField « javax.swing « Java by API






new JPasswordField(String text, int columns)

 

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JPasswordField;

public class Main extends JFrame {
  JPasswordField field = new JPasswordField("*", 10);

  public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    field.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        System.out.println("Field=" + field.getText());
      }
    });

    getContentPane().add(field);
    pack();
    setVisible(true);
  }

  public static void main(String arg[]) {
    new Main();
  }
}

   
  








Related examples in the same category

1.new JPasswordField()
2.new JPasswordField(int columns)
3.JPasswordField: getPassword()