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

📄 loginframe.java

📁 考试管理系统:实现学生信息的注册、修改、查询、删除;以及对试题进行管理:增加试题、修改试题、删除试题、查询试题
💻 JAVA
字号:
/**
 * 管理员登陆界面
 */
package edu.sccp.examManager.client;

import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.*;
import javax.swing.JTabbedPane;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import edu.sccp.examManager.tools.Tools;
import edu.sccp.examManager.business.StudentBO;
import edu.sccp.examManager.tools.FrameTools;

public class LoginFrame extends JFrame {
    JPanel contentPane;
    BorderLayout borderLayout1 = new BorderLayout();
    JTabbedPane jTabbedPane1 = new JTabbedPane();
    JPanel jPanel1 = new JPanel();
    JPanel jPanel2 = new JPanel();
    JLabel jLabel1 = new JLabel();
    JTextField adminText = new JTextField();
    JLabel jLabel2 = new JLabel();
    JButton adminLoginButton = new JButton();
    JButton adminExitButton = new JButton();
    JLabel jLabel3 = new JLabel();
    JTextField examineeText = new JTextField();
    JLabel jLabel4 = new JLabel();
    JButton examineeLoginButton = new JButton();
    JButton examineeExitButton = new JButton();
    JPasswordField adminPasswordText = new JPasswordField();
    JPasswordField examineePasswordText = new JPasswordField();

    public LoginFrame() {
        try {
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    /**
     * 界面初始化
     * @throws Exception
     */
    private void jbInit() throws Exception {
        contentPane = (JPanel) getContentPane();
        contentPane.setLayout(borderLayout1);
        this.setResizable(false);
        setSize(new Dimension(396, 304));
        setTitle("标准化考试系统登录");
        jPanel1.setLayout(null);
        jPanel1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jTabbedPane1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jTabbedPane1.setName("");
        jTabbedPane1.setBorder(null);
        jTabbedPane1.setToolTipText("");
        jLabel1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jLabel1.setText("用户名");
        jLabel1.setBounds(new Rectangle(80, 53, 67, 22));
        adminText.setBounds(new Rectangle(168, 54, 143, 22));
        jLabel2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jLabel2.setText("密码");
        jLabel2.setBounds(new Rectangle(80, 96, 42, 22));
        adminLoginButton.setBounds(new Rectangle(93, 177, 70, 26));
        adminLoginButton.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        adminLoginButton.setText("登录");
        adminLoginButton.addActionListener(new
                LoginFrame_adminLoginButton_actionAdapter(this));
        adminExitButton.setBounds(new Rectangle(202, 175, 70, 26));
        adminExitButton.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        adminExitButton.setText("退出");
        adminExitButton.addActionListener(new
                LoginFrame_adminExitButton_actionAdapter(this));
        jPanel2.setLayout(null);
        jLabel3.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jLabel3.setText("用户名");
        jLabel3.setBounds(new Rectangle(70, 44, 63, 25));
        examineeText.setText("");
        examineeText.setBounds(new Rectangle(155, 49, 131, 23));
        jLabel4.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jLabel4.setText("密码");
        jLabel4.setBounds(new Rectangle(70, 93, 44, 26));
        examineeLoginButton.setBounds(new Rectangle(86, 174, 66, 26));
        examineeLoginButton.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        examineeLoginButton.setText("登录");
        examineeLoginButton.addActionListener(new
                LoginFrame_examineeLoginButton_actionAdapter(this));
        examineeExitButton.setBounds(new Rectangle(186, 174, 66, 26));
        examineeExitButton.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        examineeExitButton.setText("退出");
        examineeExitButton.addActionListener(new
                LoginFrame_examineeExitButton_actionAdapter(this));
        adminPasswordText.setBounds(new Rectangle(168, 95, 143, 22));
        examineePasswordText.setBounds(new Rectangle(155, 96, 131, 23));
        jTabbedPane1.add(jPanel1, "管理员登录");
        jPanel1.add(jLabel1);
        jPanel1.add(adminText);
        jPanel1.add(jLabel2);
        jPanel1.add(adminExitButton);
        jPanel1.add(adminLoginButton);
        jPanel1.add(adminPasswordText);
        contentPane.add(jTabbedPane1, java.awt.BorderLayout.CENTER);
        jPanel2.add(examineeText);
        jPanel2.add(jLabel4);
        jPanel2.add(jLabel3);
        jPanel2.add(examineeExitButton);
        jPanel2.add(examineeLoginButton);
        jPanel2.add(examineePasswordText);
        jTabbedPane1.add(jPanel2, "考生登录");
    }

    /**
     * 管理员登陆按钮触发事件
     * @param e ActionEvent
     */
    public void adminLoginButton_actionPerformed(ActionEvent e) {//administrator login button action
       //获取数据
       String name = adminText.getText();
       String password = String.valueOf(adminPasswordText.getPassword());
       //数据验证
       if (name == null || name.length() == 0) {
           Tools.showDialog("用户名不能为空");
           return;
       }
       if (password == null || password.length() == 0) {
           Tools.showDialog("密码不能为空");
           return;
       }
       //把数据传给BO,并完成业务逻辑
       StudentBO stu=new StudentBO();
       if(stu.login(name,password)){
           this.dispose();
           AdminMainFrame mf = new AdminMainFrame();
           FrameTools.FrameCenter(mf);
           mf.setVisible(true);
       }else{
           Tools.showDialog("登陆失败");
       }
   }

   /**
    * 管理员退出按钮触发事件
    * @param e ActionEvent
    */
   public void adminExitButton_actionPerformed(ActionEvent e) {//administrator exit button action
        int option=Tools.showConfirmDialog("确认要退出?");
        if(option==javax.swing.JOptionPane.NO_OPTION) return;
        System.exit(0);
    }

    /**
     * 考生登陆按钮钮触发事件
     * @param e ActionEvent
     */
    public void examineeLoginButton_actionPerformed(ActionEvent e) {//examinee login button action

    }

    /**
     * 考生退出按钮钮触发事件
     * @param e ActionEvent
     */
    public void examineeExitButton_actionPerformed(ActionEvent e) {//examinee exit button action
        int option=Tools.showConfirmDialog("确认要退出?");
        if(option==javax.swing.JOptionPane.NO_OPTION) return;
        System.exit(0);
    }
}

//以下是JBuilder自动生成的代码
class LoginFrame_examineeExitButton_actionAdapter implements ActionListener {
    private LoginFrame adaptee;
    LoginFrame_examineeExitButton_actionAdapter(LoginFrame adaptee) {
        this.adaptee = adaptee;
    }
    public void actionPerformed(ActionEvent e) {
        adaptee.examineeExitButton_actionPerformed(e);
    }
}

class LoginFrame_examineeLoginButton_actionAdapter implements ActionListener {
    private LoginFrame adaptee;
    LoginFrame_examineeLoginButton_actionAdapter(LoginFrame adaptee) {
        this.adaptee = adaptee;
    }
    public void actionPerformed(ActionEvent e) {
        adaptee.examineeLoginButton_actionPerformed(e);
    }
}

class LoginFrame_adminExitButton_actionAdapter implements ActionListener {
    private LoginFrame adaptee;
    LoginFrame_adminExitButton_actionAdapter(LoginFrame adaptee) {
        this.adaptee = adaptee;
    }
    public void actionPerformed(ActionEvent e) {
        adaptee.adminExitButton_actionPerformed(e);
    }
}

class LoginFrame_adminLoginButton_actionAdapter implements ActionListener {
    private LoginFrame adaptee;
    LoginFrame_adminLoginButton_actionAdapter(LoginFrame adaptee) {
        this.adaptee = adaptee;
    }
    public void actionPerformed(ActionEvent e) {
        adaptee.adminLoginButton_actionPerformed(e);
    }
}

⌨️ 快捷键说明

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