源码编号:A-I00002
项目类型:Java SE项目(GUI图形界面)非开源
项目名称:基于Java的学生信息管理系统(student_sys)
当前版本:V2.0.1版本
开发语言:java语言
开发工具:Intellij IDEA
运行工具:Intellij IDEA完美兼容运行,Eclipse不是很友好支持
开发技术:swing、JFrame、Jdbc
项目架构:C/S
数 据 库:Mysql5.5/5.7/8.0版本
数据库表数量:2张表
是否有Eclipse版本:有
是否有代码注释:有
携带服务:远程调试服务和指导服务(问题答疑和指导)
适用场景:课程设计参考学习
功能描述:本系统属于的Java的GUI图形化界面程序,登录之后具有对学生信息增删改查的操作。
package edu.school.view;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import edu.school.entity.AppConstants;
import edu.school.entity.DAO;
import edu.school.dao.BaseDAO;
import edu.school.dao.AdminDAO;
/**
* 模块说明: 登录界面
*
*/
public class LoginView extends JFrame {
private static final long serialVersionUID = -5278598737087831336L;
private JPanel jPanelCenter, jPanelSouth;
private JTextField username;
private JPasswordField password;
private JButton loginButton, resetButton;
public LoginView() {
init();
}
private void init() {
this.setTitle("Login");
jPanelCenter = new JPanel();
jPanelCenter.setLayout(new GridLayout(3, 2));
jPanelCenter.add(new JLabel(AppConstants.LOGIN_USERNAME));
username = new JTextField();
jPanelCenter.add(username);
jPanelCenter.add(new JLabel(AppConstants.LOGIN_PASSWORD));
password = new JPasswordField();
// enter key listener
password.addKeyListener(new LoginListener());
jPanelCenter.add(password);
jPanelCenter.add(new JLabel("----------------------------------------------"));
jPanelCenter.add(new JLabel("----------------------------------------------"));
jPanelSouth = new JPanel();
jPanelSouth.setLayout(new GridLayout(1, 2));
loginButton = new JButton(AppConstants.LOGIN);
loginButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
check();
}
});
jPanelSouth.add(loginButton);
resetButton = new JButton(AppConstants.RESET);
resetButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
username.setText("");
password.setText("");
}
});
jPanelSouth.add(resetButton);
this.add(jPanelCenter, BorderLayout.CENTER);
this.add(jPanelSouth, BorderLayout.SOUTH);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.setBounds(450, 250, 375, 140);
this.setResizable(false);
this.setVisible(true);
}
private class LoginListener extends KeyAdapter {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
check();
}
}
}
private void check() {
AdminDAO adminDAO = (AdminDAO) BaseDAO.getAbilityDAO(DAO.AdminDAO);
if (adminDAO.queryForLogin(username.getText(), String.valueOf(password.getPassword()))) {
dispose();
new MainView();
} else {
username.setText("");
password.setText("");
}
}
}