首页 > 代码库 > Java swing 密码框的使用

Java swing 密码框的使用

/**
 * Java swing 密码框的使用
 * @author gao
 */
package com.gao;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.border.EmptyBorder;

public class JPasswordFieldDemo extends JFrame {
	public JPasswordFieldDemo(){
		this.setTitle("密码框的使用");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setBounds(100, 100, 250, 100);
		JPanel contentPane=new JPanel();
		contentPane.setBorder(new EmptyBorder(5,5,5,5));
		contentPane.setLayout(new BorderLayout(0,0));
		this.setContentPane(contentPane);
		JLabel label=new JLabel("密码:");
		contentPane.add(label,BorderLayout.WEST);
		JPasswordField passWordField=new JPasswordField();
		contentPane.add(passWordField,BorderLayout.CENTER);
		this.setVisible(true);
	}
   public static void main(String []args){
	   JPasswordFieldDemo example=new JPasswordFieldDemo();
   }
}