⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 login.java

📁 java(Swing) access做的成绩管理系统
💻 JAVA
字号:
package edu.xscj.test;

import javax.swing.JFrame;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import edu.xscj.action.*;
import edu.xscj.bean.*;

public class Login extends JFrame {
    XYLayout xYLayout1 = new XYLayout();
    JLabel lbUserNo = new JLabel();
    JTextField txtUserNo = new JTextField();
    JLabel lbPwd = new JLabel();
    JTextField txtPwd = new JTextField();
    JButton btnSubmit = new JButton();
    JButton btnReset = new JButton();
    JLabel lbAlert = new JLabel();


    public Login() {
        try {
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        this.getContentPane().setLayout(xYLayout1);
        lbUserNo.setText("用户名");
        txtUserNo.setText("admin");
        txtUserNo.addActionListener(new Login_txtUserNo_actionAdapter(this));
        lbPwd.setText("密码");
        txtPwd.setText("admin");
        txtPwd.addActionListener(new Login_txtPwd_actionAdapter(this));
        btnReset.setText("重填");
        btnReset.addActionListener(new Login_btnReset_actionAdapter(this));
        btnSubmit.setText("确认");
        btnSubmit.addActionListener(new Login_btnSubmit_actionAdapter(this));
        lbAlert.setForeground(Color.red);
        this.getContentPane().add(txtPwd, new XYConstraints(174, 157, 137, 26));
        this.getContentPane().add(lbUserNo, new XYConstraints(95, 98, 39, 30));
        this.getContentPane().add(lbPwd, new XYConstraints(95, 158, 38, 25));
        this.getContentPane().add(txtUserNo, new XYConstraints(175, 97, 138, 27));
        this.getContentPane().add(lbAlert, new XYConstraints(72, 37, 271, 38));
        this.getContentPane().add(btnReset, new XYConstraints(246, 224, -1, -1));
        this.getContentPane().add(btnSubmit, new XYConstraints(115, 223, 62, 27));
        this.setSize(420,350);
        this.setResizable(false);
    }


    public void btnReset_actionPerformed(ActionEvent e) {
        txtUserNo.setText("");
        txtPwd.setText("");
    }

    public void btnSubmit_actionPerformed(ActionEvent e) {
        String userNo = txtUserNo.getText();
        String userPwd = txtPwd.getText();

        btnSubmit.enable(false);
        Admin admin = new Admin();
        admin.setAdminNo(userNo);
        admin.setAdminPwd(userPwd);
        LoginAction logAction = new LoginAction();
        int i = logAction.isAvailabe(admin);
        switch (i) {
        case 1:
            MainFrame main=new MainFrame();
            this.setVisible(false);
            main.setVisible(true);

            break;

        case 2:
            lbAlert.setText("密码错误");
            break;
        case 3:
            lbAlert.setText("不存在帐号");

            break;
        case 4:
            lbAlert.setText("出错了!!!");
            break;
        }
        btnSubmit.enable(true);
    }

    public void txtUserNo_actionPerformed(ActionEvent e) {
        btnSubmit_actionPerformed(e);
    }

    public void txtPwd_actionPerformed(ActionEvent e) {
        btnSubmit_actionPerformed(e);
    }
}


class Login_txtPwd_actionAdapter implements ActionListener {
    private Login adaptee;
    Login_txtPwd_actionAdapter(Login adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.txtPwd_actionPerformed(e);
    }
}


class Login_txtUserNo_actionAdapter implements ActionListener {
    private Login adaptee;
    Login_txtUserNo_actionAdapter(Login adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.txtUserNo_actionPerformed(e);
    }
}


class Login_btnSubmit_actionAdapter implements ActionListener {
    private Login adaptee;
    Login_btnSubmit_actionAdapter(Login adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnSubmit_actionPerformed(e);
    }
}


class Login_btnReset_actionAdapter implements ActionListener {
    private Login adaptee;
    Login_btnReset_actionAdapter(Login adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnReset_actionPerformed(e);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -