package com.task17;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Login extends JFrame implements ActionListener
{
JPanel jp;
JLabel name;
JLabel password;
JLabel show;
JTextField jName;
JPasswordField jPassword;
JButton login;
JButton reset;
JButton register;
public Login(){
jp = new JPanel();
name = new JLabel("输入用户名:");
password = new JLabel("输入密码");
show = new JLabel("");
login = new JButton("登录");
reset = new JButton("重置");
register = new JButton("注册");
jName = new JTextField(10);
jPassword = new JPasswordField(10);
jPasswordField.setEchoChar('*');
jp.add(name);
jp.add(jName);
jp.add(password);
jp.add(jPassword);
jp.add(login);
jp.add(reset);
jp.add(register);
jp.add(show);
login.addActionListener(this);
reset.addActionListener(this);
register.addActionListener(this);
this.setContentPane(jp);
this.setTitle("登录窗口");
this.setSize(340,260);
boolean Visible;
this.setVisible(true);
this.setDefauleCloseOperation("JFrame.EXIT_ON_CLOSE");
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==reset){
show.setText("");
jName.setText("");
jPassword.setText("");
}
else if(e.getSource()==register){
show.setText("进入注册页面");
}
else{
if(jName.getText().equals("nonglin")&&String.valueOf(jPassword.getPassword()).equals("201600")){
show.setText("登录成功");}
else{
show.setText("对不起!用户名或密码不对");}
}}
public static void main(String args[]){
new Login();
}
}