JSP技术

package xuesheng;

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

class LoginCheck{
private String name;
private String password;
public LoginCheck(String name,String password){
this.name=name;
this.password=password;
}
public boolean equals(){
if(“root”.equals(name)&&“123456”.equals(password)){
return true;
}else{
return false;
}
}
};
class ActionHandle{
private JFrame frame=new JFrame(“学生信息管理系统”);
private JTextField name=new JTextField();//设置文本框
private JPasswordField pass=new JPasswordField();
private JLabel but1=new JLabel(“用户名:”);
private JLabel but2=new JLabel(“密 码:”);
private JButton but3=new JButton(“登录”);
private JButton but4=new JButton(“重置”);

public ActionHandle(){
    but3.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            if(e.getSource()==but3){
                String sname=name.getText();
                String spass=new String(pass.getPassword());
                LoginCheck log=new LoginCheck(sname,spass);
                if(log.equals()){
                    try {
                        new Menu();
                    } catch (Exception e1) {
                        
                        e1.printStackTrace();
                    }
                    frame.setVisible(false);
                    
                }else{
                    JOptionPane.showMessageDialog(null, "登录失败,错误的用户名或密码!");
                }
            }
        }                   
    });     
    but4.addActionListener(

new ActionListener(){
public void actionPerformed(ActionEvent e){
if(e.getSource()==but4){
name.setText("");
pass.setText("");
}
}

    });
    frame.setLayout(null);
    but1.setBounds(80, 40 , 80,30);
    name.setBounds(140,42, 120, 25);    //
    but2.setBounds(80, 80 , 80,30);
    pass.setBounds(140,82, 120, 25);
    but3.setBounds(130, 150 , 60,30);
    but4.setBounds(210, 150 , 60,30);
    frame.setSize(400,330);     
    frame.setLocation(300, 200);
    frame.add(but1);
    frame.add(name);
    frame.add(pass);
    frame.add(but2);
    frame.add(but3);
    frame.add(but4);
    frame.setVisible(true);
}

}
public class Enter{
public static void main(String[] args) {

    new ActionHandle();
}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值