自己做得简单的登录框

来源:互联网 发布:mysql基本命令 编辑:程序博客网 时间:2024/05/22 00:28
package com.chinasoft.java.am;


import java.awt.BorderLayout;


public class denglu extends JFrame {


private JPanel contentPane;
private JPasswordField passwordField_1;
private JTextField textField;
private JLabel label;
private JLabel label_1;
private JRadioButton radioButton;
private JRadioButton radioButton_1;


/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
denglu frame = new denglu();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}


/**
* Create the frame.
*/
public denglu() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//登录整个页面的大小布局
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setToolTipText("\u91CD\u7F6E");
contentPane.setBackground(new Color(51, 153, 204));
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);

JButton btnNewButton = new JButton("\u767B\u5F55");//登录按钮
btnNewButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {

if(passwordField_1.getText().equals("a7144772"))
{
new shouyin().setVisible(true);
}else
{
JOptionPane.showMessageDialog(null, "错误", "alert", JOptionPane.ERROR_MESSAGE);
}
//textField.getText();

}

});
btnNewButton.setBounds(278, 158, 70, 33);

JButton button = new JButton("\u91CD\u7F6E");//重置按钮
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new denglu().setVisible(true);
}
});
button.setBounds(91, 158, 70, 33);

passwordField_1 = new JPasswordField();//密码框
passwordField_1.setBounds(137, 99, 140, 21);//密码框的大小
contentPane.setLayout(null);
contentPane.add(button);
contentPane.add(btnNewButton);
contentPane.add(passwordField_1);

textField = new JTextField();//登录名
textField.setText("售货员");//登录框输入的内容
textField.setBounds(137, 58, 140, 21);//登录名大小
contentPane.add(textField);
textField.setColumns(10);

label = new JLabel("\u767B\u5F55\uFF1A");//登录的字
label.setForeground(Color.ORANGE);
label.setFont(new Font("宋体", Font.PLAIN, 15));
label.setBounds(77, 52, 50, 33);
contentPane.add(label);

label_1 = new JLabel("\u5BC6\u7801\uFF1A");//密码的字
label_1.setForeground(Color.ORANGE);
label_1.setFont(new Font("宋体", Font.PLAIN, 15));
label_1.setBounds(77, 93, 50, 33);
contentPane.add(label_1);

radioButton = new JRadioButton("\u8BB0\u4F4F\u8D26\u6237");
radioButton.setBounds(305, 57, 79, 23);
contentPane.add(radioButton);

radioButton_1 = new JRadioButton("\u8BB0\u4F4F\u5BC6\u7801");
radioButton_1.setBounds(305, 98, 79, 23);
contentPane.add(radioButton_1);
}
}