系统管理员登录系统,主要功能需求如下:
(1)宿舍管理员管理:能够添加管理员用户、删除管理员用户信息、查找管理员信息、修改管理员信息。
(2)学生信息管理:能够添加学生信息、删除学生信息、查找学生信息、修改学生信息、导入学生信息、导出学生信息。
(3)宿舍楼信息管理:能够添加宿舍楼信息、删除宿舍楼信息、查找宿舍楼信息、修改宿舍楼信息、导入宿舍楼信息、导出宿舍楼信息。
(4)宿舍信息管理:能够添加宿舍信息、删除宿舍信息、查找宿舍信息、修改宿舍信息、导入宿舍信息、导出宿舍信息。
(5)学生住宿管理:能够给学生分配宿舍、能够给学生调换宿舍、能够删除学生住宿信息。
(6)学生缺寝管理:学生缺寝时,能够记录学生缺寝记录,如果缺寝信息有误,学生申诉后能够修改缺寝信息、删除缺寝信息、查询学生缺寝信息。
(7)系统登录退出:能够正常登录、退出系统。
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableRowSorter;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;
import java.util.ArrayList;
public class login extends JFrame implements ActionListener {
JLabel welcome=new JLabel("欢迎使用校园宿舍管理系统");
JLabel user, password;
JTextField username;
JPasswordField passwordField;
JButton loginButton;
JButton button;
CardLayout cardLayout = new CardLayout();
JPanel card;
JPanel cardPanel,cardPanel2,cardPanel3,cardPanel4;
JTabbedPane jTabbedPane,jTabbedPane2;
int type=1;
Users users;
Font font = new Font("宋体", Font.BOLD|Font.ITALIC, 20);
public login() {
init();
}
private void init() {
welcome.setFont(font);
setTitle("宿舍管理系统");
setLayout(new BorderLayout());
user = new JLabel("用户名");
password = new JLabel("密码");
button = new JButton("重置");
card = new JPanel(cardLayout);
JPanel panel1 = new JPanel(new BorderLayout());
username = new JTextField();
passwordField = new JPasswordField();
loginButton = new JButton("登录");
loginButton.addActionListener(this);
JPanel titlepanel = new JPanel(new FlowLayout());//标题面板
JPanel loginpanel = new JPanel();//登录面板
loginpanel.setLayout(null);
welcome.setBounds(300,100,400,25);
user.setBounds(340, 170, 50, 20);
password.setBounds(340, 210, 50, 20);
username.setBounds(390, 170, 120, 20);
passwordField.setBounds(390, 210, 120, 20);
loginButton.setBounds(340, 250, 80, 25);
button.setBounds(430,250,80,25);
loginpanel.add(welcome);
loginpanel.add(user);
loginpanel.add(password);
loginpanel.add(username);
loginpanel.add(passwordField);
loginpanel.add(loginButton);
loginpanel.add(button);
panel1.add(titlepanel, BorderLayout.NORTH);
panel1.add(loginpanel, BorderLayout.CENTER);
//panel1.add(loginButton, BorderLayout.SOUTH);
card.add(panel1, "login");
//card.add(cardPanel, "info");
add(card);
setBounds(300, 100, 900, 600);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
button.addActionListener(new ActionListener(){ //为重置按钮添加监听事件
//同时清空name、password的数据
public void actionPerformed(ActionEvent arg0) {
// TODO 自动生成方法存根
username.setText("");
passwordField.setText("");
}
});
}
public static void main(String[] args) {
new login();
}
}
//代码长度过长,不在这里进行展示,需要的可以加V:ll54262818