Password Field Sample : Password Field « Swing JFC « Java






Password Field Sample

Password Field Sample
import java.awt.BorderLayout;
import java.awt.Container;

import javax.swing.Box;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class PasswordSample {
  public static void main(String args[]) {
    JFrame f = new JFrame("JPasswordField Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = f.getContentPane();
    content.setLayout(new BorderLayout());
    Box rowOne = Box.createHorizontalBox();
    rowOne.add(new JLabel("Username"));
    rowOne.add(new JTextField());
    Box rowTwo = Box.createHorizontalBox();
    rowTwo.add(new JLabel("Password"));
    rowTwo.add(new JPasswordField());
    content.add(rowOne, BorderLayout.NORTH);
    content.add(rowTwo, BorderLayout.SOUTH);
    f.setSize(300, 200);
    f.setVisible(true);
  }
}

           
       








Related examples in the same category

1.PasswordField Sample 2PasswordField Sample 2
2.Create Password fieldCreate Password field