作者主页:疯狂行者
简介:Java领域新星创作者、【计算机源码之家】公号作者✌ 简历模板、学习资料、面试题库【关注我,都给你】
文末获取源码联系
工具下载链接:
JDK版本下载
Eclipse下载链接
Mysql下载链接
tomcat下载链接
向日葵远程工具
Maven下载链接
- 计算机课程设计|毕业设计之实验室预约管理系统代码-基于Swing的实验室预约管理系统
- 前言
- 一、系统功能
- 1.1 开发环境
- 1.2 管理员功能
- 1.3 教师功能
- 1.4 学生功能
- 二、部分功能展示
- 三、部分代码设计
- 3.1.权限控制
- 3.2.主入口
- 总结
- 获取源码联系:
- Java毕设项目实战
- Java课设项目实战
前言
本次文章主要是介绍实验室预约管理系统的功能,系统有三个角色,管理员、教师、学生
一、系统功能 1.1 开发环境- 开发语言:Java
- 技术:Swing
- 数据库:MySQL
- 架构:B/S
- 源码类型: Swing
- 编译工具:Idea、Eclipse、MyEclipse (选其一)
- 其他:jdk1.8、Tomcat8.5【不需要】 、Navicat
- 登录
- 学生管理
- 教师管理
- 实验室管理
- 关于作者
- 登录
-搜索实验室
-审批
- 登录
-搜索实验室
-预约
☀️登录☀️
☀️学生预约实验室☀️
☀️教师审批☀️
☀️管理员添加学生☀️
☀️管理员之学生查询☀️
代码如下(示例):
public class Main extends Jframe {
private JPanel p;
private JLabel lblName,lblPwd,lblRole;
private JTextField txtName;
private JPasswordField txtPwd;
private JButton btnOk,btnCancle;
String[] s = {"学生","教师","管理员"};
private JComboBox comboBox;
private StudentDao studentDao=new StudentImpl();
private JLabel label;
public Main(){
super("用户登录界面");
p = new JPanel();
p.setBackground(Color.PINK);
p.setLayout(null);
lblRole=new JLabel("角色:");
lblRole.setFont(new Font("微软雅黑", Font.PLAIN, 12));
comboBox=new JComboBox(s);
comboBox.setFont(new Font("微软雅黑", Font.PLAIN, 12));
comboBox.setModel(new DefaultComboBoxModel(new String[] {"学生", "教师", "管理员"}));
lblName = new JLabel("账户:");
lblName.setFont(new Font("微软雅黑", Font.PLAIN, 12));
lblPwd = new JLabel("密码:");
lblPwd.setFont(new Font("微软雅黑", Font.PLAIN, 12));
txtName = new JTextField(20);
txtPwd = new JPasswordField(20);
btnOk = new JButton("登录");
btnOk.setFont(new Font("微软雅黑", Font.PLAIN, 12));
btnCancle = new JButton("取消");
btnCancle.setFont(new Font("微软雅黑", Font.PLAIN, 12));
//注册确定按钮的事件处理
btnOk.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String strName = txtName.getText();
String strPwd = new String(txtPwd.getPassword());
System.out.println("用户名:"+strName+"n密码:"+strPwd);
}
});
//注册取消按钮的事件处理
btnCancle.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//清空
txtName.setText("");
txtPwd.setText("");
}
});
lblRole.setBounds(90,86,60,25);
comboBox.setBounds(130,86,140,25);
lblName.setBounds(90,121,60,25);
txtName.setBounds(130,121,140,25);
lblPwd.setBounds(90,156,60,25);
txtPwd.setBounds(130,156,140,25);
btnOk.setBounds(130,191,60,25);
btnCancle.setBounds(210,191,60,25);
p.add(lblRole);
p.add(comboBox);
p.add(lblName);
p.add(txtName);
p.add(lblPwd);
p.add(txtPwd);
p.add(btnOk);
p.add(btnCancle);
getContentPane().add(p);
label = new JLabel("实验室预约管理");
label.setFont(new Font("方正舒体", Font.PLAIN, 20));
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setBounds(114, 28, 154, 25);
p.add(label);
this.setSize(400,300);
this.setLocation(300,300);
//设置窗体不可改变大小
this.setResizable(false);
this.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
btnOk.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String account =txtName.getText().trim();
String password=txtPwd.getText().trim();
String role=null;
if(comboBox.getSelectedItem().equals("管理员")){
role="admin";
}
else if(comboBox.getSelectedItem().equals("学生")) {
role="student";
}
else{
role="teacher";
}
if(role.equals("admin")){
User user=new User(account,password);
if (DB.Login(user)) {
JOptionPane.showMessageDialog(null, "登录成功", "", JOptionPane.PLAIN_MESSAGE);
AdminMainView adminMain = new AdminMainView();
adminMain.setVisible(true);
Main.this.setVisible(false);
}
else {
JOptionPane.showMessageDialog(null,"账号密码错误", "", JOptionPane.PLAIN_MESSAGE);
}
}
else if (role.equals("student")){
Student student=new Student(account,password);
if(DB.studentLogin(student)){
//查询学生信息
student = studentDao.selectStudent(student.getStudentAccount());
StudentMainView studentMain=new StudentMainView(student);
studentMain.setVisible(true);
Main.this.setVisible(false);
JOptionPane.showMessageDialog(null, "登录成功", "", JOptionPane.PLAIN_MESSAGE);
}
else {
JOptionPane.showMessageDialog(null,"账号密码错误", "", JOptionPane.PLAIN_MESSAGE);
}
}
else if (role.equals("teacher")){
Teacher teacher=new Teacher(account,password);
if(DB.teacherLogin(teacher)){
TeacherMainView teacherMain=new TeacherMainView();
teacherMain.setVisible(true);
Main.this.setVisible(false);
JOptionPane.showMessageDialog(null, "登录成功", "", JOptionPane.PLAIN_MESSAGE);
}
else {
JOptionPane.showMessageDialog(null,"账号密码错误", "", JOptionPane.PLAIN_MESSAGE);
}
}
}
});
btnCancle.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
}
});
}
3.2.主入口
代码如下(示例):
public static void main(String[] args) {
// write your code here
Font font = new Font("微软雅黑",Font.PLAIN, 14);
UIManager.put("Table.font", font);
WebLookAndFeel.globalControlFont = new FontUIResource(font);
WebLookAndFeel.install();
try {
UIManager.setLookAndFeel(new WebLookAndFeel());
Main main=new Main();
main.setVisible(true);
} catch (UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
总结
获取源码联系:
大家点赞、收藏、关注、评论啦 、查看微信公众号获取联系方式
打卡 文章 更新 18/ 365天
精彩专栏推荐订阅:在 下方专栏
Java毕设项目实战 Java课设项目实战



