前言:

这是我学java时,写的一个练手项目,主要用来巩固知识,还有很多地方并不完善,有很多不足之处,仅供参考。

另外,如果直接按着我的代码敲很可能会出现bug。这大概率时JDK或MySQL的版本问题,需要各位自行上网查找解决(这是一位程序员的基本能力),这些问题一般比较简单,网上都有解决方法。

几次实机演示,与版本更新视频:

大二软工日常之《写点小玩意儿》

大二软工生的日常生活之《项目优化》

大二软工生的日常之《项目优化2》

代码部分:

view部分:

view.ui.StudentSystem

package view.ui;
import model.dao.MySQL;public class StudentSystem {public static LoginFrame login;public static RegisterFrame register;public static ManageAppFrame manage;public static CommonAppFrame common;public static ChangeAccountFrame change;public static ChangeOwnAccountFrame changeown;public static DeleteAccountFrame delete;public static SelectAccountFrame select;public static void main(String[] args) {new MySQL();login = new LoginFrame();
//      manage = new ManageAppFrame();}
}

view.ui.LoginFrame


import javax.swing.*;import controller.activity.ActionEvents;
import view.utils.Fronts;
/*** @项目名称:StudentSystem_GUI* @包名称:com.window* @类名称:MyFrames* @类描述:登陆界面* @创建人:青春玩命的年代* @创建时间:2021年11月12日* @版本:*/
public class LoginFrame extends JFrame {private static final long serialVersionUID = 1L;//消除警告用的,我也不知道是啥//声明标签、文本、密码、按钮组件private JLabel bgimg, account, password, title;public static JTextField accountField;public static JPasswordField passwordField;public static JButton login, register;private Toolkit tool = getToolkit();private Image image = tool.getImage("src/img/2.jpg");private ImageIcon img = new ImageIcon("src/img/18.png");//图片private JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.CENTER));//存放标题private JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.CENTER));//存放账号密码标签和文本框private final int WIDTH = 550;private final int HEIGHT = 338;private final int LEFT = 550;private final int UP = 200;private final int TEXTLENGTH = 15;public LoginFrame() {//设置图标setIconImage(image);setTitle("登陆界面");//设置标题setBounds(LEFT, UP, WIDTH, HEIGHT);//设置窗口大小位置setVisible(true);//设置窗口可见setResizable(false);//设置窗口的拉伸setDefaultCloseOperation(EXIT_ON_CLOSE);//设置窗口的退出LoadFrame();}private void LoadFrame() {//设置面板组件LoadPanel();//设置标签组件LoadLabel();//设置文本组件LoadField();//设置按钮组件LoadButten();//设置监听事件LoadActionListener();//进行组件插入LoadAdd();//让组件生效validate();}private void LoadPanel() {panel1.setBounds(0, 0, WIDTH, HEIGHT/4);panel1.setOpaque(false);//设置面板透明panel2.setBounds(WIDTH/6, HEIGHT/4, WIDTH/3*2, HEIGHT/4*3);panel2.setOpaque(false);//设置面板透明}private void LoadLabel() {bgimg = new JLabel(img);bgimg.setBounds(0, 0, img.getIconWidth(), img.getIconHeight());title = new JLabel("学生信息管理系统");title.setFont(Fronts.fronts.title);//设置字体title.setForeground(Color.CYAN);//设置字体颜色account = new JLabel("账号:");account.setFont(Fronts.fronts.account);//设置字体account.setForeground(Color.CYAN);//设置字体颜色password = new JLabel("密码:");password.setFont(Fronts.fronts.password);//设置字体password.setForeground(Color.CYAN);//设置字体颜色}private void LoadField() {accountField = new JTextField(TEXTLENGTH);accountField.setFont(Fronts.fronts.account);//设置字体accountField.setForeground(Color.BLACK);//设置字体颜色passwordField = new JPasswordField(TEXTLENGTH);passwordField.setFont(Fronts.fronts.password);//设置字体passwordField.setForeground(Color.BLACK);//设置字体颜色}private void LoadButten() {login = new JButton("登录");login.setFont(Fronts.fronts.login);//设置字体login.setForeground(Color.BLACK);//设置字体颜色login.setBackground(new Color(150, 150, 150));//设置按钮背景颜色register = new JButton("注册");register.setFont(Fronts.fronts.register);//设置字体register.setForeground(Color.BLACK);//设置字体颜色register.setBackground(new Color(150, 150, 150));//设置按钮背景颜色}private void LoadActionListener() {SetName();accountField.addActionListener(ActionEvents.event);passwordField.addActionListener(ActionEvents.event);login.addActionListener(ActionEvents.event);register.addActionListener(ActionEvents.event);}private void LoadAdd() {panel1.add(title);panel2.add(account);panel2.add(accountField);panel2.add(password);panel2.add(passwordField);panel2.add(login);panel2.add(register);add(panel1);add(panel2);add(bgimg);}private void SetName(){accountField.setName("accountField_login");passwordField.setName("passwordField_login");login.setName("login_login");register.setName("register_login");}
}

view.ui.RegisterFrame:

package view.ui;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Image;
import java.awt.Toolkit;import javax.swing.*;import controller.activity.ActionEvents;
import view.utils.Fronts;
/*** @项目名称:StudentSystem_GUI* @包名称:com.window* @类名称:Register* @类描述:注册功能* @创建人:青春玩命的年代* @创建时间:2021年11月12日* @版本:*/
public class RegisterFrame extends JFrame{private static final long serialVersionUID = 1L;//消除警告用的,我也不知道是啥private JLabel bgimg, name,account, password, repassword,title;public static JTextField nameField,accountField;public static JPasswordField passwordField,repasswordField;public static JButton register, exit;private Toolkit tool = getToolkit();private Image image = tool.getImage("src/img/2.jpg");private ImageIcon img = new ImageIcon("src/img/24.jpg");//图片private JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.CENTER));//存放标题private JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.CENTER));//存放账号密码标签和文本框//参数:private final int WIDTH = 640;private final int HEIGHT = 472;private final int LEFT = 200;private final int UP = 100;private final int TEXTLENGTH = 20;public  RegisterFrame() {setIconImage(image);setTitle("注册界面");//设置标题setBounds(LEFT, UP, WIDTH, HEIGHT);//设置窗口大小位置setVisible(true);//设置窗口可见setResizable(true);//设置窗口的拉伸setDefaultCloseOperation(DISPOSE_ON_CLOSE);//设置窗口的退出LoadFrame();}private void LoadFrame() {//设置面板组件LoadPanel();//设置标签组件LoadLabel();//设置文本组件LoadField();//设置按钮组件LoadButten();//设置监听事件LoadActionListener();//设置组件添加LoadAdd();//让组件生效validate();}private void LoadPanel() {panel1.setBounds(0, HEIGHT/6, WIDTH, HEIGHT/6);panel1.setOpaque(false);//设置面板透明panel2.setBounds(WIDTH/10, HEIGHT/6*2, WIDTH/5*4, HEIGHT/6*4);panel2.setOpaque(false);//设置面板透明}private void LoadLabel() {bgimg = new JLabel(img);bgimg.setBounds(0, 0, img.getIconWidth(), img.getIconHeight());title = new JLabel("学生信息管理系统账号注册");title.setFont(Fronts.fronts.re_title);//设置字体title.setForeground(new Color(80, 80, 80));//设置字体颜色name = new JLabel("姓    名:");name.setFont(Fronts.fronts.re_account);//设置字体name.setForeground(Color.BLACK);//设置字体颜色account = new JLabel("账    号:");account.setFont(Fronts.fronts.re_account);//设置字体account.setForeground(Color.BLACK);//设置字体颜色password = new JLabel("密    码:");password.setFont(Fronts.fronts.re_password);//设置字体password.setForeground(Color.BLACK);//设置字体颜色repassword = new JLabel("确认密码:");repassword.setFont(Fronts.fronts.re_password);//设置字体repassword.setForeground(Color.BLACK);//设置字体颜色}private void LoadField() {nameField = new JTextField(TEXTLENGTH);nameField.setFont(Fronts.fronts.re_account);//设置字体nameField.setForeground(Color.BLACK);//设置字体颜色accountField = new JTextField(TEXTLENGTH);accountField.setFont(Fronts.fronts.re_account);//设置字体accountField.setForeground(Color.BLACK);//设置字体颜色passwordField = new JPasswordField(TEXTLENGTH);passwordField.setFont(Fronts.fronts.re_password);//设置字体passwordField.setForeground(Color.BLACK);//设置字体颜色repasswordField = new JPasswordField(TEXTLENGTH);repasswordField.setFont(Fronts.fronts.re_password);//设置字体repasswordField.setForeground(Color.BLACK);//设置字体颜色}private void LoadButten() {register = new JButton("确认注册");register.setFont(Fronts.fronts.re_register);//设置字体register.setForeground(Color.BLACK);//设置字体颜色register.setBackground(new Color(150, 150, 150));//设置按钮背景颜色exit = new JButton("退    出");exit.setFont(Fronts.fronts.re_register);//设置字体exit.setForeground(Color.BLACK);//设置字体颜色exit.setBackground(new Color(150, 150, 150));//设置按钮背景颜色}private void LoadActionListener() {SetName();nameField.addActionListener(ActionEvents.event);accountField.addActionListener(ActionEvents.event);passwordField.addActionListener(ActionEvents.event);repasswordField.addActionListener(ActionEvents.event);register.addActionListener(ActionEvents.event);exit.addActionListener(ActionEvents.event);}private void LoadAdd() {panel1.add(title);panel2.add(name);panel2.add(nameField);panel2.add(account);panel2.add(accountField);panel2.add(password);panel2.add(passwordField);panel2.add(repassword);panel2.add(repasswordField);panel2.add(register);panel2.add(exit);add(panel1);add(panel2);add(bgimg);}private void SetName() {nameField.setName("nameField_register");accountField.setName("accountField_register");passwordField.setName("passwordField_register");repasswordField.setName("repasswordField_register");register.setName("register_register");exit.setName("exit_register");}
}

view.ui.ManageAppFrame:

package view.ui;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.util.Vector;/*** * @项目名称:StudentSystem_GUI* @包名称:com.window* @类名称:ManageFrame* @类描述:管理员账号的应用界面* @创建人:青春玩命的年代* @创建时间:2021年11月13日* @版本:*/
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;import controller.activity.ActionEvents;
import view.utils.Fronts;public class ManageAppFrame extends JFrame{private static final long serialVersionUID = 1L;//消除警告用的,我也不知道是啥private Toolkit tool = getToolkit();private Image image = tool.getImage("src/img/2.jpg");//背景图片private ImageIcon imgManage = new ImageIcon("src/img/1.jpg");//定义菜单private JMenuBar menubar;private JMenu menu1, menu2;private JMenuItem item1_1,item1_2, item1_3, item1_4, item2_1, item2_2;//定义标签、文本、文本域按钮private JLabel bgimg, name, age, classes, number, key;public static JTextField nameField, ageField, classesField, numberField, keyField;public static JButton add, delete, change, show, reset;public static JTextArea area = new JTextArea();;//定义单选按钮组件private ButtonGroup group = null;public static JRadioButton Men, Women, AllSex;//定义表格public static JTextArea resultArea = area;//显示结果private JTable table;private Object columns[] = {"姓名", "性别", "年龄", "班级", "学号"};public static DefaultTableModel model;static Vector<String> rwo;static Object a[][];static int row ;static TableColumnModel columnModel;//定义面板JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));//存放标题JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.CENTER));//存放账号密码标签和文本框JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.LEFT));//存放账号密码标签和文本框JPanel panel4 = new JPanel(new FlowLayout(FlowLayout.LEFT));//存放账号密码标签和文本框//定义滚动窗口JScrollPane scrollPanel1;JScrollPane scrollPanel2;private final int WIDTH = 672;private final int HEIGHT = 583;private final int LEFT = 500;private final int UP = 30;private final int TEXTLENGTH = 10;public ManageAppFrame() {setIconImage(image);setTitle("管理员界面");//设置标题setBounds(LEFT, UP, WIDTH, HEIGHT);//设置窗口大小位置setVisible(true);//设置窗口可见setResizable(false);//设置窗口的拉伸setDefaultCloseOperation(EXIT_ON_CLOSE);//设置窗口的退出LoadFrame();}private void LoadFrame() {//设置面板组件LoadPanel();//设置菜单组件LoadMenu();//设置标签组件LoadLabel();//设置文本组件LoadField();//设置单选按钮组件LoadButtonGroup();//设置按钮组件LoadButten();//设置表格LoadTable();//设置信息域LoadArea();//设置监听事件LoadActionListener();//进行组件插入LoadAdd();//让组件生效validate();}private void LoadPanel() {panel1.setBounds(0, 0, WIDTH, HEIGHT/20);panel1.setOpaque(false);//设置面板透明panel2.setBounds(0, HEIGHT/20, WIDTH, HEIGHT/20*3);panel2.setOpaque(false);//设置面板透明panel2.setBorder(BorderFactory.createTitledBorder("基本信息处理"));panel3.setBounds(0, HEIGHT/5, WIDTH, HEIGHT/10*5);panel3.setOpaque(false);//设置面板透明panel3.setBorder(BorderFactory.createTitledBorder("学生数据信息显示"));panel4.setBounds(0, HEIGHT/10*7, WIDTH, HEIGHT/10*3);panel4.setOpaque(false);//设置面板透明panel4.setBorder(BorderFactory.createTitledBorder("账号信息显示"));}private void LoadMenu() {menubar = new JMenuBar();menu1 = new JMenu("普通账号管理");menu1.setBackground(new Color(230, 230, 235));//设置按钮背景颜色menu2 = new JMenu("功能");menu2.setBackground(new Color(230, 230, 235));//设置按钮背景颜色item1_1 = new JMenuItem("精确查看普通账号信息",new  ImageIcon("src/img/3.jpg"));item1_2 = new JMenuItem("查看所有普通账号信息",new  ImageIcon("src/img/3.jpg"));item1_2.setBackground(new Color(230, 230, 235));//设置按钮背景颜色item1_3 = new JMenuItem("更改普通账号信息",new  ImageIcon("src/img/3.jpg"));item1_3.setBackground(new Color(230, 230, 235));//设置按钮背景颜色item1_4 = new JMenuItem("删除普通账号",new  ImageIcon("src/img/3.jpg"));item1_4.setBackground(new Color(230, 230, 235));//设置按钮背景颜色item2_1 = new JMenuItem("修改密码",new  ImageIcon("src/img/5.jpg"));item2_1.setBackground(new Color(230, 230, 235));//设置按钮背景颜色item2_2 = new JMenuItem("使用指南",new  ImageIcon("src/img/5.jpg"));item2_2.setBackground(new Color(230, 230, 235));//设置按钮背景颜色}private void LoadLabel() {bgimg = new JLabel(imgManage);name = new JLabel("姓名:");name.setFont(Fronts.fronts.ma_name);//设置字体name.setForeground(Color.BLACK);//设置字体颜色age = new JLabel("年龄:");age.setFont(Fronts.fronts.ma_age);//设置字体age.setForeground(Color.BLACK);//设置字体颜色classes = new JLabel("班级:");classes.setFont(Fronts.fronts.ma_classes);//设置字体classes.setForeground(Color.BLACK);//设置字体颜色number = new JLabel("学号:");number.setFont(Fronts.fronts.ma_number);//设置字体number.setForeground(Color.BLACK);//设置字体颜色key = new JLabel("筛选条件(学号):");key.setFont(Fronts.fronts.ma_number);//设置字体key.setForeground(Color.BLACK);//设置字体颜色}private void LoadField() {nameField = new JTextField(TEXTLENGTH);nameField.setFont(Fronts.fronts.ma_name);//设置字体nameField.setForeground(Color.BLACK);//设置字体颜色ageField = new JTextField(TEXTLENGTH);ageField.setFont(Fronts.fronts.ma_age);//设置字体ageField.setForeground(Color.BLACK);//设置字体颜色classesField = new JTextField(TEXTLENGTH);classesField.setFont(Fronts.fronts.ma_classes);//设置字体classesField.setForeground(Color.BLACK);//设置字体颜色numberField = new JTextField(TEXTLENGTH);numberField.setFont(Fronts.fronts.ma_number);//设置字体numberField.setForeground(Color.BLACK);//设置字体颜色keyField = new JTextField(TEXTLENGTH);keyField.setFont(Fronts.fronts.key);//设置字体keyField.setForeground(Color.BLACK);//设置字体颜色}private void LoadButtonGroup() {group=new ButtonGroup();Men=new JRadioButton("男");Women=new JRadioButton("女");AllSex=new JRadioButton("全部");}private void LoadButten() {add = new JButton("添加数据");add.setFont(Fronts.fronts.ma_add);//设置字体add.setForeground(Color.BLACK);//设置字体颜色add.setBackground(new Color(230, 230, 235));//设置按钮背景颜色delete = new JButton("删除数据");delete.setFont(Fronts.fronts.ma_delete);//设置字体delete.setForeground(Color.BLACK);//设置字体颜色delete.setBackground(new Color(230, 230, 235));//设置按钮背景颜色change = new JButton("修改数据");change.setFont(Fronts.fronts.ma_change);//设置字体change.setForeground(Color.BLACK);//设置字体颜色change.setBackground(new Color(230, 230, 235));//设置按钮背景颜色show = new JButton("查询数据");show.setFont(Fronts.fronts.ma_change);//设置字体show.setForeground(Color.BLACK);//设置字体颜色show.setBackground(new Color(230, 230, 235));//设置按钮背景颜色reset = new JButton("重置");reset.setFont(Fronts.fronts.ma_change);//设置字体reset.setForeground(Color.BLACK);//设置字体颜色reset.setBackground(new Color(230, 230, 235));//设置按钮背景颜色setForeground(Color.BLACK);//设置字体颜色}void LoadTable() {table = getTable();scrollPanel1 = new JScrollPane(table);scrollPanel1.setPreferredSize(new Dimension(WIDTH-30,250));//给窗格设置大小table.setPreferredSize(new Dimension(WIDTH-30,10000));//给表格设置大小scrollPanel1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);//将滑动组件显示在窗口中scrollPanel1.setOpaque(false);//设置面板透明table.setOpaque(false);//设置面板透明}void LoadArea() {scrollPanel2 = new JScrollPane(area);scrollPanel2.setPreferredSize(new Dimension(WIDTH-30,100));//给窗格设置大小area.setPreferredSize(new Dimension(WIDTH-50,10000));//给表格设置大小scrollPanel2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);//将滑动组件显示在窗口中area.setOpaque(false);//设置面板透明area.setEditable(false); }private void LoadActionListener() {SetName();item1_1.addActionListener(ActionEvents.event);item1_2.addActionListener(ActionEvents.event);item1_3.addActionListener(ActionEvents.event);item1_4.addActionListener(ActionEvents.event);item2_1.addActionListener(ActionEvents.event);item2_2.addActionListener(ActionEvents.event);add.addActionListener(ActionEvents.event);delete.addActionListener(ActionEvents.event);change.addActionListener(ActionEvents.event);show.addActionListener(ActionEvents.event);reset.addActionListener(ActionEvents.event);}private void LoadAdd() {menu1.add(item1_1);menu1.add(item1_2);menu1.add(item1_3);menu1.add(item1_4);menu2.add(item2_1);menu2.add(item2_2);menubar.add(menu1);menubar.add(menu2);group.add(Men);group.add(Women);group.add(AllSex);panel1.add(menubar);panel2.add(name);panel2.add(nameField);panel2.add(Men);panel2.add(Women);panel2.add(AllSex);panel2.add(age);panel2.add(ageField);panel2.add(classes);panel2.add(classesField);panel2.add(number);panel2.add(numberField);panel2.add(key);panel2.add(keyField);panel2.add(add);panel2.add(delete);panel2.add(change);panel2.add(show);panel2.add(reset);panel3.add(scrollPanel1);panel4.add(scrollPanel2);add(panel1);add(panel2);add(panel3);add(panel4);add(bgimg);}private void SetName(){item1_1.setName("item1_1");item1_2.setName("item1_2");item1_3.setName("item1_3");item1_4.setName("item1_4");item2_1.setName("item2_1");item2_2.setName("item2_2");add.setName("add_ma");delete.setName("delete_ma");change.setName("change_ma");show.setName("show_ma");reset.setName("reset_ma");}private JTable getTable() {if(table == null) {table = new JTable();//创建 table.setOpaque(false);//设置表格透明int[] columnWidth={150,150,150,150,150};//设置列宽model = new DefaultTableModel(){public boolean isCellEditable(int row, int column){return false;}};//列宽 和行数  并且让表格不可编辑model.setColumnIdentifiers(columns);table.setModel(model);//设置为表格的模式columnModel=table.getColumnModel();//获取到表格的控制table.getTableHeader().setReorderingAllowed(false);//让表格不可拖动table.getTableHeader().setResizingAllowed(false);//让表格不可拖动int count=columnModel.getColumnCount();//返回列数和行数for(int i=0;i<count;i++){TableColumn column=columnModel.getColumn(i);//返回列表中的对象column.setPreferredWidth(columnWidth[i]);}rwo = new Vector<String>(5);}return table;}public void close() {this.dispose();}
}

view.ui.CommonAppFrame:

package view.ui;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.util.Vector;/*** * @项目名称:StudentSystem_GUI* @包名称:com.window* @类名称:ManageFrame* @类描述:管理员账号的应用界面* @创建人:青春玩命的年代* @创建时间:2021年11月13日* @版本:*/
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;import controller.activity.ActionEvents;
import view.utils.Fronts;public class CommonAppFrame extends JFrame{private static final long serialVersionUID = 1L;//消除警告用的,我也不知道是啥private Toolkit tool = getToolkit();private Image image = tool.getImage("src/img/2.jpg");//定义菜单private JMenuBar menubar;private JMenu menu;private JMenuItem item1, item2, item3;//背景图片private ImageIcon imgManage = new ImageIcon("src/img/1.jpg");//定义标签、文本、文本域按钮private JLabel bgimg, name, age, classes, number, key;public static JTextField nameField, ageField, classesField, numberField, keyField;public static JButton show, reset;//定义单选按钮组件ButtonGroup group = null;public static JRadioButton Men, Women, AllSex;//定义表格private JTable table;private Object columns[] = {"姓名", "性别", "年龄", "班级", "学号"};public static DefaultTableModel  model;static Vector<String> rwo;static Object a[][];static int row ;static TableColumnModel columnModel;//定义面板private JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));//存放账号密码标签和文本框private JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.CENTER));//存放账号密码标签和文本框private JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.LEFT));//存放账号密码标签和文本框//定义滚动窗口private JScrollPane scrollPanel;private final int WIDTH = 672;private final int HEIGHT = 583;private final int LEFT = 500;private final int UP = 30;private final int TEXTLENGTH = 10;public CommonAppFrame() {setIconImage(image);setTitle("普通用户界面");//设置标题setBounds(LEFT, UP, WIDTH, HEIGHT);//设置窗口大小位置setVisible(true);//设置窗口可见setResizable(false);//设置窗口的拉伸setDefaultCloseOperation(EXIT_ON_CLOSE);//设置窗口的退出LoadFrame();}private void LoadFrame() {//设置面板组件LoadPanel();//设置菜单组件LoadMenu();//设置标签组件LoadLabel();//设置文本组件LoadField();//设置单选按钮组件LoadButtonGroup();//设置按钮组件LoadButten();//设置表格LoadTable();//设置监听事件LoadActionListener();//进行组件插入LoadAdd();//让组件生效validate();}private void LoadPanel() {panel1.setBounds(0, 0, WIDTH, HEIGHT/20);panel1.setOpaque(false);//设置面板透明panel2.setBounds(0, HEIGHT/20, WIDTH, HEIGHT/20*3);panel2.setOpaque(false);//设置面板透明panel2.setBorder(BorderFactory.createTitledBorder("基本信息处理"));panel3.setBounds(0, HEIGHT/5, WIDTH, HEIGHT/5*4);panel3.setOpaque(false);//设置面板透明panel3.setBorder(BorderFactory.createTitledBorder("学生数据信息显示"));}private void LoadMenu() {menubar = new JMenuBar();menubar.setBackground(new Color(230, 230, 235));//设置按钮背景颜色menu = new JMenu("功能");menu.setBackground(new Color(230, 230, 235));//设置按钮背景颜色item1 = new JMenuItem("修改密码",new  ImageIcon("src/img/3.jpg"));item1.setBackground(new Color(230, 230, 235));//设置按钮背景颜色item2 = new JMenuItem("注销",new  ImageIcon("src/img/3.jpg"));item2.setBackground(new Color(230, 230, 235));//设置按钮背景颜色item3 = new JMenuItem("使用指南",new  ImageIcon("src/img/3.jpg"));item3.setBackground(new Color(230, 230, 235));//设置按钮背景颜色}private void LoadLabel() {bgimg = new JLabel(imgManage);name = new JLabel("姓名:");name.setFont(Fronts.fronts.ma_name);//设置字体name.setForeground(Color.BLACK);//设置字体颜色age = new JLabel("年龄:");age.setFont(Fronts.fronts.ma_age);//设置字体age.setForeground(Color.BLACK);//设置字体颜色classes = new JLabel("班级:");classes.setFont(Fronts.fronts.ma_classes);//设置字体classes.setForeground(Color.BLACK);//设置字体颜色number = new JLabel("学号:");number.setFont(Fronts.fronts.ma_number);//设置字体number.setForeground(Color.BLACK);//设置字体颜色key = new JLabel("筛选条件(学号)");key.setFont(Fronts.fronts.key);//设置字体key.setForeground(Color.BLACK);//设置字体颜色}private void LoadField() {nameField = new JTextField(TEXTLENGTH);nameField.setFont(Fronts.fronts.ma_name);//设置字体nameField.setForeground(Color.BLACK);//设置字体颜色ageField = new JTextField(TEXTLENGTH);ageField.setFont(Fronts.fronts.ma_age);//设置字体ageField.setForeground(Color.BLACK);//设置字体颜色classesField = new JTextField(TEXTLENGTH);classesField.setFont(Fronts.fronts.ma_classes);//设置字体classesField.setForeground(Color.BLACK);//设置字体颜色numberField = new JTextField(TEXTLENGTH);numberField.setFont(Fronts.fronts.ma_number);//设置字体numberField.setForeground(Color.BLACK);//设置字体颜色keyField = new JTextField(TEXTLENGTH);keyField.setFont(Fronts.fronts.ma_number);//设置字体keyField.setForeground(Color.BLACK);//设置字体颜色}private void LoadButtonGroup() {group=new ButtonGroup();Men=new JRadioButton("男");Women=new JRadioButton("女");AllSex=new JRadioButton("全部");}private void LoadButten() {show = new JButton("查找数据");show.setFont(Fronts.fronts.ma_show);//设置字体show.setForeground(Color.BLACK);//设置字体颜色show.setBackground(new Color(230, 230, 235));//设置按钮背景颜色reset = new JButton("重置");reset.setFont(Fronts.fronts.ma_show);//设置字体reset.setForeground(Color.BLACK);//设置字体颜色reset.setBackground(new Color(230, 230, 235));//设置按钮背景颜色}void LoadTable() {table = getTable();scrollPanel = new JScrollPane(table);scrollPanel.setPreferredSize(new Dimension(WIDTH-30,300));//给窗格设置大小table.setPreferredSize(new Dimension(WIDTH-30,10000));//给表格设置大小scrollPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);//将滑动组件显示在窗口中}private void LoadActionListener() {SetName();show.addActionListener(ActionEvents.event);reset.addActionListener(ActionEvents.event);item1.addActionListener(ActionEvents.event);item2.addActionListener(ActionEvents.event);item3.addActionListener(ActionEvents.event);}private void LoadAdd() {group.add(Men);group.add(Women);group.add(AllSex);panel1.add(menubar);panel2.add(name);panel2.add(nameField);panel2.add(Men);panel2.add(Women);panel2.add(AllSex);panel2.add(age);panel2.add(ageField);panel2.add(classes);panel2.add(classesField);panel2.add(number);panel2.add(numberField);panel2.add(key);panel2.add(keyField);panel2.add(show);panel2.add(reset);panel3.add(scrollPanel);menubar.add(menu);menu.add(item1);menu.add(item2);menu.add(item3);add(panel1);add(panel2);add(panel3);add(bgimg);}private void SetName(){item1.setName("item1");item2.setName("item2");item3.setName("item3");show.setName("show_co");reset.setName("reset_co");}private JTable getTable() {if(table == null) {table = new JTable();//创建 table.setOpaque(false);//设置表格透明int[] columnWidth={150,150,150,150,150};//设置列宽model = new DefaultTableModel(){public boolean isCellEditable(int row, int column){return false;}};//列宽 和行数  并且让表格不可编辑model.setColumnIdentifiers(columns);table.setModel(model);//设置为表格的模式columnModel=table.getColumnModel();//获取到表格的控制table.getTableHeader().setReorderingAllowed(false);//让表格不可拖动table.getTableHeader().setResizingAllowed(false);//让表格不可拖动int count=columnModel.getColumnCount();//返回列数和行数for(int i=0;i<count;i++){TableColumn column=columnModel.getColumn(i);//返回列表中的对象column.setPreferredWidth(columnWidth[i]);}rwo = new Vector<String>(5);}return table;}public void close() {this.dispose();}
}

view.ui.ChangeAccountFrame:

package view.ui;import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Image;
import java.awt.Toolkit;import javax.swing.*;import controller.activity.ActionEvents;public class ChangeAccountFrame extends JFrame{private static final long serialVersionUID = 1L;//消除警告用的,我也不知道是啥//声明标签、文本、密码、按钮组件private JLabel account, name, password;public static JTextField accountField, nameField;public static JPasswordField passwordField;public static JButton change;private Toolkit tool = getToolkit();private Image image = tool.getImage("src/img/3.jpg");//设置窗口大小和初始位置的参数private final int WIDTH = 250;private final int HEIGHT = 150;private final int LEFT = 230;private final int UP = 160;//设置文本的长度参数private final int TEXTLENGTH = 15;public ChangeAccountFrame() {setIconImage(image);//设置图标setTitle("更改账户信息");//设置标题setLayout(new FlowLayout(FlowLayout.CENTER));//设置窗口布局setBounds(LEFT, UP, WIDTH, HEIGHT);//设置窗口大小位置setVisible(true);//设置窗口可见setResizable(true);//设置窗口的拉伸setDefaultCloseOperation(DISPOSE_ON_CLOSE);//设置窗口的退出LoadFrame();//设置窗口的组件}private void LoadFrame() {//设置标签组件LoadLabel();//设置文本组件LoadField();//设置按钮组件LoadButten();//设置监听事件LoadActionListener();//进行组件插入LoadAdd();//加载组件validate();}private void LoadLabel() {name = new JLabel("姓    名:");account = new JLabel("账    号:");password = new JLabel("新密码:");}private void LoadField() {nameField = new JTextField(TEXTLENGTH);accountField = new JTextField(TEXTLENGTH);passwordField = new JPasswordField(TEXTLENGTH);}private void LoadButten() {change = new JButton("确认更改");change.setBackground(new Color(230, 230, 235));//设置按钮背景颜色}private void LoadActionListener() {SetName();change.addActionListener(ActionEvents.event);nameField.addActionListener(ActionEvents.event);accountField.addActionListener(ActionEvents.event);passwordField.addActionListener(ActionEvents.event);}private void LoadAdd() {add(name);add(nameField);add(account);add(accountField);add(password);add(passwordField);add(change);}private void SetName(){change.setName("change_change");nameField.setName("nameField_change");accountField.setName("accountField_change");passwordField.setName("passwordField_change");}
}

view.ui.ChangeOwnAccountFrame:

package view.ui;import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Image;
import java.awt.Toolkit;import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;import controller.activity.ActionEvents;public class ChangeOwnAccountFrame extends JFrame{private static final long serialVersionUID = 1L;//消除警告用的,我也不知道是啥//声明标签、文本、密码、按钮组件private JLabel name, password;public static JTextField nameField;public static JPasswordField passwordField;public static JButton change;private Toolkit tool = getToolkit();private Image image = tool.getImage("src/img/5.jpg");//设置窗口大小和初始位置的参数private final int WIDTH = 250;private final int HEIGHT = 150;private final int LEFT = 230;private final int UP = 160;//设置文本的长度参数private final int TEXTLENGTH = 15;public ChangeOwnAccountFrame() {setIconImage(image);//设置图标setTitle("修改密码");//设置标题setLayout(new FlowLayout(FlowLayout.CENTER));//设置窗口布局setBounds(LEFT, UP, WIDTH, HEIGHT);//设置窗口大小位置setVisible(true);//设置窗口可见setResizable(true);//设置窗口的拉伸setDefaultCloseOperation(DISPOSE_ON_CLOSE);//设置窗口的退出LoadFrame();//设置窗口的组件}private void LoadFrame() {//设置标签组件LoadLabel();//设置文本组件LoadField();//设置按钮组件LoadButten();//设置监听事件LoadActionListener();//进行组件插入LoadAdd();//加载组件validate();}private void LoadLabel() {name = new JLabel("姓    名:");password = new JLabel("新密码:");}private void LoadField() {nameField = new JTextField(TEXTLENGTH);passwordField = new JPasswordField(TEXTLENGTH);}private void LoadButten() {change = new JButton("确认修改");change.setBackground(new Color(230, 230, 235));//设置按钮背景颜色}private void LoadActionListener() {SetName();nameField.addActionListener(ActionEvents.event);passwordField.addActionListener(ActionEvents.event);change.addActionListener(ActionEvents.event);}private void LoadAdd() {add(name);add(nameField);add(password);add(passwordField);add(change);}private void SetName(){nameField.setName("nameField_changeown");passwordField.setName("passwordField_changeown");change.setName("change_changeown");}
}

view.ui.DeleteAccountFrame:

package view.ui;import java.awt.*;
import javax.swing.*;import controller.activity.ActionEvents;public class DeleteAccountFrame extends JFrame {private static final long serialVersionUID = 1L;//消除警告用的,我也不知道是啥//声明标签、文本、密码、按钮组件private JLabel account;public static JTextField accountField;public static JButton delete;private Toolkit tool = getToolkit();private Image image = tool.getImage("src/img/3.jpg");//设置窗口大小和初始位置的参数private final int WIDTH = 250;private final int HEIGHT = 100;private final int LEFT = 230;private final int UP = 160;//设置文本的长度参数private final int TEXTLENGTH = 15;public DeleteAccountFrame() {setIconImage(image);//设置图标setTitle("删除账户");//设置标题setLayout(new FlowLayout(FlowLayout.CENTER));//设置窗口布局setBounds(LEFT, UP, WIDTH, HEIGHT);//设置窗口大小位置setVisible(true);//设置窗口可见setResizable(true);//设置窗口的拉伸setDefaultCloseOperation(DISPOSE_ON_CLOSE);//设置窗口的退出LoadFrame();//设置窗口的组件}private void LoadFrame() {//设置标签组件LoadLabel();//设置文本组件LoadField();//设置按钮组件LoadButten();//设置监听事件LoadActionListener();//进行组件插入LoadAdd();//加载组件validate();}private void LoadLabel() {account = new JLabel("账号:");}private void LoadField() {accountField = new JTextField(TEXTLENGTH);}private void LoadButten() {delete = new JButton("确认删除");delete.setBackground(new Color(230, 230, 235));//设置按钮背景颜色}private void LoadActionListener() {SetName();delete.addActionListener(ActionEvents.event);}private void LoadAdd() {add(account);add(accountField);add(delete);}private void SetName(){delete.setName("delete_delete");}
}

view.ui.SelectAccountFrame:

package view.ui;
import java.awt.*;
import javax.swing.*;import controller.activity.ActionEvents;
public class SelectAccountFrame extends JFrame{private static final long serialVersionUID = 1L;//消除警告用的,我也不知道是啥//声明标签、文本、密码、按钮组件private JLabel account;public static JTextField accountField;public static JButton select;private Toolkit tool = getToolkit();private Image image = tool.getImage("src/img/3.jpg");//设置窗口大小和初始位置的参数private final int WIDTH = 250;private final int HEIGHT = 100;private final int LEFT = 230;private final int UP = 160;//设置文本的长度参数private final int TEXTLENGTH = 15;public SelectAccountFrame() {setIconImage(image);//设置图标setTitle("选择账户");//设置标题setLayout(new FlowLayout(FlowLayout.CENTER));//设置窗口布局setBounds(LEFT, UP, WIDTH, HEIGHT);//设置窗口大小位置setVisible(true);//设置窗口可见setResizable(true);//设置窗口的拉伸setDefaultCloseOperation(DISPOSE_ON_CLOSE);//设置窗口的退出LoadFrame();//设置窗口的组件}private void LoadFrame() {//设置标签组件LoadLabel();//设置文本组件LoadField();//设置按钮组件LoadButten();//设置监听事件LoadActionListener();//进行组件插入LoadAdd();//加载组件validate();}private void LoadLabel() {account = new JLabel("账号:");}private void LoadField() {accountField = new JTextField(TEXTLENGTH);}private void LoadButten() {select = new JButton("确认");select.setBackground(new Color(230, 230, 235));//设置按钮背景颜色}private void LoadActionListener() {SetName();select.addActionListener(ActionEvents.event);}private void LoadAdd() {add(account);add(accountField);add(select);}private void SetName(){select.setName("select_select");}
}

view.ui.HelpCommonFrame:

package view.ui;import java.awt.*;import javax.swing.*;public class HelpCommonFrame extends JFrame{private static final long serialVersionUID = 1L;//消除警告用的,我也不知道是啥//声明标签、文本、密码、按钮组件String text1,text2,text3,text4,text5;public JTextArea area = new JTextArea();JScrollPane scrollPanel;private Toolkit tool = getToolkit();private Image image = tool.getImage("src/img/3.jpg");//设置窗口大小和初始位置的参数private final int WIDTH = 400;private final int HEIGHT = 400;private final int LEFT = 230;private final int UP = 160;public HelpCommonFrame() {setIconImage(image);//设置图标setTitle("使用指南");//设置标题setLayout(new FlowLayout(FlowLayout.CENTER));//设置窗口布局setBounds(LEFT, UP, WIDTH, HEIGHT);//设置窗口大小位置setVisible(true);//设置窗口可见setResizable(false);//设置窗口的拉伸setDefaultCloseOperation(DISPOSE_ON_CLOSE);//设置窗口的退出LoadText();scrollPanel = new JScrollPane(area);scrollPanel.setPreferredSize(new Dimension(WIDTH-30,350));//给窗格设置大小area.setPreferredSize(new Dimension(WIDTH-50,800));//给表格设置大小scrollPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);//将滑动组件显示在窗口中area.setOpaque(false);//设置面板透明area.setEditable(false); area.setLineWrap(true);area.setBounds(10, 0, WIDTH-20, 1000);area.setFont(new Font("宋体",Font.PLAIN,18));//设置字体area.setForeground(Color.BLACK);//设置字体颜色area.append(text1);area.append(text2);add(scrollPanel);validate();}private void LoadText() {text1 = "1.查询数据:\n①精准查询:\n  输入筛选条件(学号)点击“查询数据”按钮,即可完成查询。\n②条件查询:\n  输入第一行的任意几个条件,点击查询按钮,即可完成查询(第一行的学号位的作用是学号含有该数字的数据会被查询)\n③全局查询:  不输入任何信息,直接点击“查询数据”,会查询所有数据\n";text2 = "2.重置:\n  清空所有条件。";}
}

view.ui.HelpManageFrame:

package view.ui;import java.awt.*;
import javax.swing.*;public class HelpManageFrame extends JFrame{private static final long serialVersionUID = 1L;//消除警告用的,我也不知道是啥//声明标签、文本、密码、按钮组件String text1,text2,text3,text4,text5;public JTextArea area = new JTextArea();JScrollPane scrollPanel;private Toolkit tool = getToolkit();private Image image = tool.getImage("src/img/3.jpg");//设置窗口大小和初始位置的参数private final int WIDTH = 400;private final int HEIGHT = 400;private final int LEFT = 230;private final int UP = 160;public HelpManageFrame() {setIconImage(image);//设置图标setTitle("使用指南");//设置标题setLayout(new FlowLayout(FlowLayout.CENTER));//设置窗口布局setBounds(LEFT, UP, WIDTH, HEIGHT);//设置窗口大小位置setVisible(true);//设置窗口可见setResizable(false);//设置窗口的拉伸setDefaultCloseOperation(DISPOSE_ON_CLOSE);//设置窗口的退出LoadText();scrollPanel = new JScrollPane(area);scrollPanel.setPreferredSize(new Dimension(WIDTH-30,350));//给窗格设置大小area.setPreferredSize(new Dimension(WIDTH-50,800));//给表格设置大小scrollPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);//将滑动组件显示在窗口中area.setOpaque(false);//设置面板透明area.setEditable(false); area.setLineWrap(true);area.setBounds(10, 0, WIDTH-20, 1000);area.setFont(new Font("宋体",Font.PLAIN,18));//设置字体area.setForeground(Color.BLACK);//设置字体颜色area.append(text1);area.append(text2);area.append(text3);area.append(text4);area.append(text5);add(scrollPanel);validate();}private void LoadText() {text1 = "1.添加数据:\n  在第一行输入姓名、性别、年龄、班级、学号,点击“添加数据”按钮即可完成添加数据的操作。\n";text2 = "2.删除数据:\n  输入筛选信息点击“删除数据”的按钮即可完成删除数据的操作。\n ";text3 = "3.修改数据:\n  输入筛选条件(学号)选择数据,在第一行输入修改的信息,点击“修改数据”的按钮即可完成修改数据的操作\n  注意:\n    修改的数据学号不能与其他人的学号重复\n";text4 = "4.查询数据:\n①精准查询:\n  输入筛选条件(学号)点击“查询数据”按钮,即可完成查询。\n②条件查询:\n  输入第一行的任意几个条件,点击查询按钮,即可完成查询(第一行的学号位的作用是学号含有该数字的数据会被查询)\n③全局查询:  不输入任何信息,直接点击“查询数据”,会查询所有数据\n";text5 = "5.重置:\n  清空所有条件。";}
}

view.utils.Fronts:

package view.utils;import java.awt.*;
/*** @项目名称:StudentSystem_GUI* @包名称:com.stytle* @类名称:Fronts* @类描述:存储改变字体的方法* @创建人:青春玩命的年代* @创建时间:2021年11月12日* @版本:*/
public class Fronts {public static Fronts fronts = new Fronts();public Font title;public Font account;public Font password;public Font login;public Font register;public Font re_title;public Font re_account;public Font re_password;public Font re_register;public Font ma_name;public Font ma_age;public Font ma_classes;public Font ma_number;public Font ma_add;public Font ma_delete;public Font ma_change;public Font ma_show;public Font ma_reset;public Font key;public Fronts() {title = new Font("宋体", Font.BOLD, 40);//字体和大小account = new Font("宋体", Font.BOLD, 30);//字体和大小password = new Font("宋体", Font.BOLD, 30);//字体和大小login = new Font("宋体", Font.BOLD, 26);//字体和大小register = new Font("宋体", Font.BOLD, 26);//字体和大小re_title = new Font("宋书", Font.BOLD, 40);//字体和大小re_account = new Font("宋体", Font.BOLD, 25);//字体和大小re_password = new Font("宋体", Font.BOLD, 25);//字体和大小re_register = new Font("宋体", Font.BOLD, 21);//字体和大小ma_name = new Font("宋体", Font.TRUETYPE_FONT, 14);ma_age = new Font("宋体", Font.TRUETYPE_FONT, 14);ma_classes = new Font("宋体", Font.TRUETYPE_FONT, 14);ma_number = new Font("宋体", Font.TRUETYPE_FONT, 14);ma_add = new Font("宋体", Font.TRUETYPE_FONT, 12);ma_delete = new Font("宋体", Font.TRUETYPE_FONT, 12);ma_change = new Font("宋体", Font.TRUETYPE_FONT, 12);ma_show = new Font("宋体", Font.TRUETYPE_FONT, 12);ma_reset = new Font("宋体", Font.TRUETYPE_FONT, 12);key = new Font("宋体", Font.TRUETYPE_FONT, 12);}
}

controller部分:

controller.activity.ActionEvents:

package controller.activity;import java.awt.event.*;import javax.swing.*;
import java.sql.*;
import view.ui.*;
/*** @项目名称:StudentSystem_GUI* @包名称:com.event* @类名称:ButtonEvent* @类描述:按钮监听器* @创建人:青春玩命的年代* @创建时间:2021年11月12日* @版本:*/
public class ActionEvents implements ActionListener{public static ActionEvents event = new ActionEvents();public static String ACCOUNT;//记录当前登录的账号public static String level;//记录当前登录的账号JButton button;JTextField field;JMenuItem item;Statement sql;ResultSet rs;@Overridepublic void actionPerformed(ActionEvent e) {try {new FieldEvents(e, field);}catch(Exception e1) {try {new ButtonEvents(e,button);}catch (ClassCastException e2) {try {new ItemEvents(e, item);}catch(Exception e3) {}}}                    }public static void addOneAble(ResultSet rs) {String  data[]=new String [5];try {rs.next();data[0]=rs.getString(1) ;data[1]=rs.getString(2) ;data[2]=rs.getString(3) ;data[3]=rs.getString(4) ;data[4]=rs.getString(5) ;ManageAppFrame.nameField.setText(data[0]);if(data[1].equals("男")) {ManageAppFrame.Men.setSelected(true);}else if(data[1].equals("女")) {ManageAppFrame.Women.setSelected(true);}ManageAppFrame.ageField.setText(data[2]);ManageAppFrame.classesField.setText(data[3]);ManageAppFrame.numberField.setText(data[4]);ManageAppFrame.model.addRow(data);       }catch(SQLException e) {}}
}

controller.activity.ButtonEvents

package controller.activity;import java.awt.event.ActionEvent;import javax.swing.JButton;import controller.service.CommonAppFrameMethod;
import controller.service.LoginFrameMethod;
import controller.service.ManageAppFrameMethod;
import controller.service.RegisterFrameMethod;
import model.dao.MySQL;
import view.ui.StudentSystem;public class ButtonEvents {public ButtonEvents(ActionEvent e, JButton button) {button= (JButton) e.getSource();if(button.getName() == "register_register") {RegisterFrameMethod.RegisterMethod();}if(button.getName() == "exit_register") {RegisterFrameMethod.ExitMethod();}if(button.getName() == "register_login") {LoginFrameMethod.RegisterMethod();}if(button.getName() == "login_login") {LoginFrameMethod.LoginMethod();}if(button.getName() == "change_change") {ManageAppFrameMethod.ChangeCommonAccountMessage();}if(button.getName() == "change_changeown") {ManageAppFrameMethod.ChangeOwnAccountMessage();}if(button.getName() == "delete_delete") {ManageAppFrameMethod.DeleteCommonAccountMessage();}if(button.getName() == "select_select") {MySQL.OneAccount();ActionEvents.level = "user";}if(button.getName() == "add_ma") {ManageAppFrameMethod.AddMethod();}if(button.getName() == "delete_ma") {ManageAppFrameMethod.DeletMethod();}if(button.getName() == "change_ma") {ManageAppFrameMethod.ChangeMethod();}if(button.getName() == "show_ma") {ManageAppFrameMethod.ShowMethod();}if(button.getName() == "reset_ma") {StudentSystem.manage.nameField.setText("");StudentSystem.manage.ageField.setText("");StudentSystem.manage.classesField.setText("");StudentSystem.manage.numberField.setText("");StudentSystem.manage.keyField.setText("");}if(button.getName() == "reset_co") {StudentSystem.common.nameField.setText("");StudentSystem.common.ageField.setText("");StudentSystem.common.classesField.setText("");StudentSystem.common.numberField.setText("");StudentSystem.common.keyField.setText("");}if(button.getName() == "show_co") {CommonAppFrameMethod.ShowMethod();}}
}

controller.activity.FieldEvents

package controller.activity;import java.awt.event.ActionEvent;import javax.swing.JTextField;import controller.service.ChangeFrameMethod;
import controller.service.ChangeOwnFrameMethod;
import controller.service.LoginFrameMethod;
import controller.service.RegisterFrameMethod;public class FieldEvents {public FieldEvents(ActionEvent e, JTextField field) {field = (JTextField) e.getSource();if(field != null) {RegisterFrameMethod.FieldMethod(field);LoginFrameMethod.FieldMethod(field);ChangeFrameMethod.FieldMethod(field);ChangeOwnFrameMethod.FieldMethod(field);}}
}

controller.activity.ItemEvents

package controller.activity;import java.awt.event.ActionEvent;
import javax.swing.JMenuItem;import model.dao.MySQL;
import view.ui.*;public class ItemEvents {public ItemEvents(ActionEvent e, JMenuItem item) {item=(JMenuItem) e.getSource();if(item.getName()=="item1_1") {StudentSystem.select = new SelectAccountFrame();}if(item.getName()=="item1_2") {MySQL.AllAccount();ActionEvents.level = "user";}if(item.getName()=="item1_3") {StudentSystem.change = new ChangeAccountFrame();ActionEvents.level = "user";}if(item.getName()=="item1_4") {StudentSystem.delete = new DeleteAccountFrame();ActionEvents.level = "user";}if(item.getName()=="item2_1") {StudentSystem.changeown = new ChangeOwnAccountFrame();ActionEvents.level = "user_manage";}if(item.getName()=="item2_2") {new HelpManageFrame();}if(item.getName()=="item1") {StudentSystem.changeown = new ChangeOwnAccountFrame();ActionEvents.level = "user";}if(item.getName()=="item2") {StudentSystem.common.close();MySQL.DeletMethod_User(ActionEvents.ACCOUNT);ActionEvents.level = "user";}if(item.getName()=="item3") {new HelpCommonFrame();}}
}

controller.service.ChangeFrameMethod

package controller.service;import javax.swing.JTextField;import view.ui.ChangeAccountFrame;public class ChangeFrameMethod {//换行功能public static void FieldMethod(JTextField field) {if(field.getName()=="nameField_change"){ChangeAccountFrame.accountField.requestFocus();}if(field.getName()=="accountField_change") {ChangeAccountFrame.passwordField.requestFocus();}if(field.getName()=="passwordField_change") {ChangeAccountFrame.change.requestFocus();}}
}

controller.service.ChangeOwnAccountFrame

package controller.service;import javax.swing.JTextField;
import view.ui.ChangeOwnAccountFrame;public class ChangeOwnFrameMethod {//换行功能public static void FieldMethod(JTextField field) {if(field.getName()=="nameField_changeown"){System.out.println("changow");ChangeOwnAccountFrame.passwordField.requestFocus();}if(field.getName()=="passwordField_changeown") {ChangeOwnAccountFrame.change.requestFocus();}}
}

controller.service.CommonAppFrameMethod

package controller.service;import view.ui.*;public class CommonAppFrameMethod {//查询数据public static void ShowMethod() {ManageAppFrame.nameField = CommonAppFrame.nameField;ManageAppFrame.ageField = CommonAppFrame.ageField;ManageAppFrame.classesField = CommonAppFrame.classesField;ManageAppFrame.numberField = CommonAppFrame.numberField;ManageAppFrame.keyField = CommonAppFrame.keyField;ManageAppFrame.Men = CommonAppFrame.Men;ManageAppFrame.Women = CommonAppFrame.Women;ManageAppFrame.AllSex = CommonAppFrame.AllSex;ManageAppFrame.model = CommonAppFrame.model;ManageAppFrameMethod.ShowMethod();}
}

controller.service.LoginFrameMethod

package controller.service;import javax.swing.*;import controller.activity.ActionEvents;
import model.dao.MySQL;
import view.ui.*;public class LoginFrameMethod {//换行功能public static void FieldMethod(JTextField field) {if(field.getName()=="accountField_login") {LoginFrame.passwordField.requestFocus();}if(field.getName()=="passwordField_login") {LoginFrame.login.requestFocus();}}//打开注册页面public static void RegisterMethod() {StudentSystem.register = new RegisterFrame();StudentSystem.login.dispose();}//打开应用页面public static void LoginMethod() {//获取账号密码String account=LoginFrame.accountField.getText();String passworn=new String (LoginFrame.passwordField.getPassword());//记录当前登陆的账号ActionEvents.ACCOUNT = account;//判断该账户是管理员账户或普通账户或错误账户,并进入相应的页面或退出if(MySQL.LoginMethod_User(account, passworn)) {StudentSystem.common = new CommonAppFrame();//进入普通界面ActionEvents.level = "user";//关闭登陆页面StudentSystem.login.dispose();}else if(MySQL.LoginMethod_UserManage( account, passworn)) {StudentSystem.manage = new ManageAppFrame();//进入管理员界面ActionEvents.level = "user_manage";//关闭登陆页面StudentSystem.login.dispose();}else {JOptionPane.showMessageDialog(null, "密码错误", "登录消息",JOptionPane.WARNING_MESSAGE);StudentSystem.login.passwordField.setText("");}}
}

controller.service.ManageAppFrameMethod

package controller.service;import java.sql.*;
import javax.swing.JOptionPane;import controller.activity.ActionEvents;
import model.dao.MySQL;
import view.ui.*;public class ManageAppFrameMethod {//修改普通账号的信息public static void ChangeCommonAccountMessage() {//获取姓名、账号、密码String name = ChangeAccountFrame.nameField.getText();String account = ChangeAccountFrame.accountField.getText();String password = new String (ChangeAccountFrame.passwordField.getPassword());//修改User表的信息MySQL.ChangeMethod(name, account, password);StudentSystem.change.dispose();}//修改当前账号信息public static void ChangeOwnAccountMessage() {//获取姓名、账号、密码String name = new String (ChangeOwnAccountFrame.nameField.getText());String account = ActionEvents.ACCOUNT;System.out.println(ActionEvents.ACCOUNT);System.out.println(ActionEvents.level);String password = new String (ChangeOwnAccountFrame.passwordField.getPassword());//修改User表的信息MySQL.ChangeMethod(name, account, password);StudentSystem.changeown.dispose();}//删除普通账号public static void DeleteCommonAccountMessage() {//获取账号String account = DeleteAccountFrame.accountField.getText();//修改User表的信息MySQL.DeletMethod_User(account);}//增添数据public static void AddMethod() {//获取输入的姓名、性别、年龄、班级、学号String name = ManageAppFrame.nameField.getText();boolean man=ManageAppFrame.Men.isSelected();boolean woman=ManageAppFrame.Women.isSelected();boolean AllSex=ManageAppFrame.AllSex.isSelected();String sex;String age=ManageAppFrame.ageField.getText();String grade=ManageAppFrame.classesField.getText();String number=ManageAppFrame.numberField.getText();//保护机制if(name.equals("")) {JOptionPane.showMessageDialog(null, "姓名不能为空", "编辑消息",JOptionPane.WARNING_MESSAGE);}else if((man==false&&woman==false)&&AllSex==true) {ManageAppFrame.Men.setSelected(true);JOptionPane.showMessageDialog(null, "”全部“在增加信息不能被选中", "编辑消息",JOptionPane.WARNING_MESSAGE);      }else if(man==false&&woman==false&&AllSex==false) {JOptionPane.showMessageDialog(null, "请选则性别", "编辑消息",JOptionPane.WARNING_MESSAGE);}else if( age.equals("")) {JOptionPane.showMessageDialog(null, "年纪不能为空", "编辑消息",JOptionPane.WARNING_MESSAGE);}else if ( grade.equals("")) {JOptionPane.showMessageDialog(null, "班级不能为空", "编辑消息",JOptionPane.WARNING_MESSAGE);}else if(number.equals("")) {JOptionPane.showMessageDialog(null, "学号不能为空", "编辑消息",JOptionPane.WARNING_MESSAGE);}else {if(ManageAppFrame.Men.isSelected()==true) {sex=ManageAppFrame.Men.getText();}else {sex=ManageAppFrame.Women.getText();}//将添加的数据插入数据库中    MySQL.AddMethod_Student(name, sex, age, grade, number);//将添加的数据显示到表格里面ShowTable(name, sex, age, grade, number);}}//删除数据public static void DeletMethod() {//删除数据String key = ManageAppFrame.keyField.getText();if(key.equals("")) {JOptionPane.showMessageDialog(null, "条件框不能为空", "删除消息",JOptionPane.WARNING_MESSAGE);}else {MySQL.DeletMethod_Student(key);}}//修改数据public static void ChangeMethod() {//获取被修改的同学学号String key = ManageAppFrame.keyField.getText();//获取修改后的信息String name = ManageAppFrame.nameField.getText();boolean man = ManageAppFrame.Men.isSelected();boolean woman = ManageAppFrame.Women.isSelected();boolean allsex = ManageAppFrame.AllSex.isSelected();String sex;String age = ManageAppFrame.ageField.getText();String grade = ManageAppFrame.classesField.getText();String number = ManageAppFrame.numberField.getText();//保护机制if(key.equals("")) {JOptionPane.showMessageDialog(null, "条件框学号不能为空", "删除消息",JOptionPane.WARNING_MESSAGE);}else   if(name.equals("")) {JOptionPane.showMessageDialog(null, "姓名不能为空", "编辑消息",JOptionPane.WARNING_MESSAGE);}else if((man==false&&woman==false)&&allsex==true) {ManageAppFrame.Men.setSelected(true);JOptionPane.showMessageDialog(null, "”全部“在增加信息不能被选中", "编辑消息",JOptionPane.WARNING_MESSAGE);}else if(man==false&&woman==false&&allsex==false) {JOptionPane.showMessageDialog(null, "请选则性别", "编辑消息",JOptionPane.WARNING_MESSAGE);}else if( age.equals("")) {JOptionPane.showMessageDialog(null, "年纪不能为空", "编辑消息",JOptionPane.WARNING_MESSAGE);}else if ( grade.equals("")) {JOptionPane.showMessageDialog(null, "班级不能为空", "编辑消息",JOptionPane.WARNING_MESSAGE);}else if(number.equals("")) {JOptionPane.showMessageDialog(null, "学号不能为空", "编辑消息",JOptionPane.WARNING_MESSAGE);}else {if(ManageAppFrame.Men.isSelected()==true) {sex=ManageAppFrame.Men.getText();}else {sex=ManageAppFrame.Women.getText();}//修改数据库信息MySQL.ChangeMethod_Student(name, sex, age , grade, number, key);}}//查询数据public static void ShowMethod() {//获取主键信息String key = ManageAppFrame.keyField.getText();//单条信息//获取查找条件String sex = "";String name=ManageAppFrame.nameField.getText();boolean Man=ManageAppFrame.Men.isSelected();boolean Woman=ManageAppFrame.Women.isSelected();boolean AllSex=ManageAppFrame.AllSex.isSelected();if(!Man&&!Woman&&!AllSex) {ManageAppFrame.AllSex.setSelected(true);//选中AllSex}String age=ManageAppFrame.ageField.getText();String grade=ManageAppFrame.classesField.getText();String number=ManageAppFrame.numberField.getText();if(ManageAppFrame.Men.isSelected()==true) {sex=ManageAppFrame.Men.getText();}else if(ManageAppFrame.Women.isSelected()==true){sex=ManageAppFrame.Women.getText();}//如果主键为空if(key.equals("")) {if(name.equals("")&&AllSex&&age.equals("")&&grade.equals("")&&number.equals("")) {MySQL.ShowAllMethod_Student();}else {//查找条件消息的if(name.equals("")) {name=".*?";}if(sex.equals("")) {sex=".*?";}if(age.equals("")) {age=".*?";}if(grade.equals("")) {grade=".*?";}if(number.equals("")) {number=".*?";}MySQL.ShowConMethod_Student(name,sex,age,grade,number);}} else if(!key.equals("")) {MySQL.ShowOneMethod_Student(key);}}public static void AddTable(ResultSet rs) {String  data[]=new String [5];try {while(rs.next()) {data[0]=rs.getString(1) ;data[1]=rs.getString(2) ;data[2]=rs.getString(3) ;data[3]=rs.getString(4) ;data[4]=rs.getString(5) ;ManageAppFrame.model.addRow(data);}}catch(SQLException e) {}}private static void ShowTable(String name, String sex, String age, String grade, String number) {String[] data=new String [5];data[0]=name;data[1]=sex;data[2]=age;data[3]=grade;data[4]=number;ManageAppFrame.model.addRow(data);}
}

controller.service.RegisterFrameMethod

package controller.service;import javax.swing.*;
import model.dao.MySQL;
import view.ui.LoginFrame;
import view.ui.RegisterFrame;
import view.ui.StudentSystem;public class RegisterFrameMethod {//换行功能public static void FieldMethod(JTextField field) {if(field.getName()=="nameField_register") {RegisterFrame.accountField.requestFocus();}if(field.getName()=="accountField_register") {RegisterFrame.passwordField.requestFocus();}if(field.getName()=="passwordField_register") {RegisterFrame.repasswordField.requestFocus();}if(field.getName()=="repasswordField_register"){RegisterFrame.register.requestFocus();}}//注册功能public static void RegisterMethod()  {boolean nameFlag = RegisterFrame.nameField.getText().equals("");boolean accountFlag = RegisterFrame.accountField.getText().equals("");//获取密码char[] str=RegisterFrame.passwordField.getPassword();String passwordField = new String(str);boolean passwordFlag = passwordField.equals("");//获取重复输入的密码str=RegisterFrame.repasswordField.getPassword();String repasswordField = new String(str);boolean repasswordFlag = repasswordField.equals("");if(nameFlag == true) {JOptionPane.showMessageDialog(null, "姓名不能为空", "注册消息",JOptionPane.WARNING_MESSAGE);}else if(accountFlag == true){JOptionPane.showMessageDialog(null, "账号不能为空", "注册消息",JOptionPane.WARNING_MESSAGE);}else if(passwordFlag==true) {JOptionPane.showMessageDialog(null, "密码不能为空", "注册消息",JOptionPane.WARNING_MESSAGE);}else if(repasswordFlag==true) {JOptionPane.showMessageDialog(null, "确认密码不能为空", "注册消息",JOptionPane.WARNING_MESSAGE);}else if(passwordField.equals(repasswordField)==false){//如果确认密码和密码是不一样的JOptionPane.showMessageDialog(null, "密码输入不一致", "注册消息",JOptionPane.WARNING_MESSAGE);}else {//获取姓名、账号、密码String name=RegisterFrame.nameField.getText();String account=RegisterFrame. accountField.getText();String password= passwordField;//将账号信息传入数据库内MySQL.AddUser(name, account, password);;}}//退出注册页面public static void ExitMethod() {StudentSystem.register.dispose();StudentSystem.login = new LoginFrame();}//清除文本内容public static void CloseTextField() {StudentSystem.register.nameField.setText("");StudentSystem.register.accountField.setText("");StudentSystem.register.passwordField.setText("");StudentSystem.register.repasswordField.setText("");}}

Model部分:

model.dao.MySQL:

package model.dao;import java.sql.*;import controller.activity.ActionEvents;
import model.service.*;
import view.ui.*;public class MySQL {public static Connection con=null;final String JDBCNAME = "com.mysql.jdbc.Driver";final String URL = "jdbc:mysql://localhost:3306/student?characterEncoding=utf-8&useSSL=false";final String ACCOUNT = "root";final String PASSWORD = "MS122166";public MySQL() {//第一步:加载驱动  ConnectMySQL.LoadDriver(JDBCNAME);//第二步连接数据库ConnectMySQL.LoadConnect(URL, ACCOUNT, PASSWORD);}//将账号输入数据库public static void AddUser(String name, String account, String password) {String URI = "insert into user values(?,?,?)";AddMySQL.AddUser(URI, name, account, password);}//判断输入账号是否是普通用户public static boolean LoginMethod_User(String account, String password) {String URI="select account,password from user";return OtherMySQL.CompareMethod(URI, account, password);}//判断输入账号是否是管理员用户public static boolean LoginMethod_UserManage(String account, String password) {String URI = "select account,password from user_manage";return OtherMySQL.CompareMethod(URI, account, password);}//更改User表的信息public static void ChangeMethod(String name, String account, String password) {String URI;if(ActionEvents.level.equals("user_manage")) {URI = "update user_manage set name=?,password=? where account=?";}else {URI = "update user set name=?,password=? where account=?";}ChangeMySQL.ChangeMethod(URI, name, account, password);}//删除User表中的数据public static void DeletMethod_User(String account) {String URI = "delete from user where account=?";DeleteMySQL.DeleteMethod(URI, account);}public static void AllAccount() {Statement sql;ResultSet rs;String URI="select * from user";try {sql=con.createStatement();rs=sql.executeQuery(URI);ManageAppFrame.resultArea.setText("");ManageAppFrame.resultArea.setText("姓名\t账号\t密码\n");while(rs.next()) {String name = rs.getString(1);//返回的第一个值就是账号String account = rs.getString(2);//返回的第一个值就是账号String password = rs.getString(3);//返回的第一个值就是账号String URI1 = ManageAppFrame.resultArea.getText()+name+"\t"+account+"\t"+password+"\n";ManageAppFrame.resultArea.setText(URI1);}}catch(SQLException e) {}}public static void OneAccount() {ResultSet rs = null;String URI = "select * from user where account=?";String key = SelectAccountFrame.accountField.getText();try {PreparedStatement preSql;preSql = MySQL.con.prepareStatement(URI);preSql.setString(1, key);rs=preSql.executeQuery();ManageAppFrame.resultArea.setText("");ManageAppFrame.resultArea.setText("姓名\t账号\t密码\n");rs.next();String name = rs.getString(1);String account = rs.getString(2);String password = rs.getString(3);String URI1 = ManageAppFrame.resultArea.getText()+name+"\t"+account+"\t"+password+"\n";ManageAppFrame.resultArea.setText(URI1);StudentSystem.select.dispose();   }catch(SQLException e) {System.out.println(e);}}//将信息插入student表当中public static void AddMethod_Student(String name, String sex, String age, String grade, String number) {String URI = "insert into student(name,sex,age,grade,number)values(?,?,?,?,?)";AddMySQL.AddStudent(URI, name, sex, age, grade, number);}//删除student表里面的数据public static void DeletMethod_Student(String key) {String URI = "delete from student where number=?";DeleteMySQL.DeleteMethod(URI, key);}public static void ChangeMethod_Student(String name,String sex,String age,String grade,String number,String key) {String URI = "update student  set name=?,sex=?,age=?,grade=?,number=? where number=?";ChangeMySQL.ChangeMethod1(URI, name, sex, age, grade, number, key);}public static void ShowAllMethod_Student() {String URI = "select * from student";//查找所有的ShowMySQL.ShowAllMethod(URI);}public static void ShowConMethod_Student(String name, String sex, String age, String grade, String number) {String URI = "select * from student where name REGEXP? and sex REGEXP? and age REGEXP? and grade REGEXP? and number REGEXP?";//查找所有的ShowMySQL.ShowConMethod(URI, name, sex, age, grade, number);}public static void ShowOneMethod_Student(String key) {ManageAppFrame.model.setNumRows(0);//将表格数据为0String URI = "select * from student where number=?";ShowMySQL.ShowOneMethod(URI, key);}
}

model.service.AddMySQL

package model.service;import java.sql.*;
import javax.swing.JOptionPane;
import controller.service.RegisterFrameMethod;
import model.dao.MySQL;public class AddMySQL {public static void AddUser(String URI, String name, String account, String password){PreparedStatement preSql;try {preSql = MySQL.con.prepareStatement("insert into user values(?,?,?)");preSql.setString(1, name);preSql.setString(2, account);preSql.setString(3, password);preSql.executeUpdate();JOptionPane.showMessageDialog(null, "注册成功", "注册消息",JOptionPane.WARNING_MESSAGE);RegisterFrameMethod.CloseTextField();}catch(SQLException e) {System.out.println(e);JOptionPane.showMessageDialog(null, "当前账号已经存在", "注册消息",JOptionPane.WARNING_MESSAGE);}}public static void AddStudent(String URI, String name, String sex, String age, String grade, String number) {try {PreparedStatement preSql;preSql = MySQL.con.prepareStatement(URI);preSql.setString(1, name);preSql.setString(2, sex);preSql.setString(3, age);preSql.setString(4, grade);preSql.setString(5, number);preSql.executeUpdate();JOptionPane.showMessageDialog(null, "添加成功", "添加数据",JOptionPane.WARNING_MESSAGE);}catch(SQLException e) {JOptionPane.showMessageDialog(null, "当前学号已经存在", "添加数据",JOptionPane.WARNING_MESSAGE);}}
}

model.service.ChangeMySQL

package model.service;import java.sql.PreparedStatement;
import java.sql.SQLException;import javax.swing.JOptionPane;import model.dao.MySQL;public class ChangeMySQL {public static void ChangeMethod(String URI, String name, String account,String password) {try {System.out.println(URI);PreparedStatement preSql;preSql = MySQL.con.prepareStatement(URI);if(account.equals("")) {JOptionPane.showMessageDialog(null, "账号不能为空", "更改消息",JOptionPane.WARNING_MESSAGE);}else if (name.equals("")) {JOptionPane.showMessageDialog(null, "姓名不能为空", "更改消息",JOptionPane.WARNING_MESSAGE);}else if (password.equals("")) {JOptionPane.showMessageDialog(null, "密码不能为空", "更改消息",JOptionPane.WARNING_MESSAGE);}else {preSql.setString(1, name);preSql.setString(2,password);preSql.setString(3, account);int number = preSql.executeUpdate();if(number == 0) {JOptionPane.showMessageDialog(null, "请输入正确账号", "更改消息",JOptionPane.WARNING_MESSAGE);}else {JOptionPane.showMessageDialog(null, "更改成功", "更改消息",JOptionPane.WARNING_MESSAGE);}}}catch(SQLException e) {}}public static void ChangeMethod1(String URI, String name, String sex, String age, String grade, String number, String key) {try {PreparedStatement preSql;preSql = MySQL.con.prepareStatement(URI);preSql.setString(1, name);preSql.setString(2, sex);preSql.setString(3, age);preSql.setString(4, grade);preSql.setString(5, number);preSql.setString(6, key);int account = preSql.executeUpdate();if(account == 0) {JOptionPane.showMessageDialog(null, "学号重复或者输入学号不存在", "消息",JOptionPane.WARNING_MESSAGE);}else {JOptionPane.showMessageDialog(null, "更改成功", "消息",JOptionPane.WARNING_MESSAGE);}}catch(SQLException e) { }}}

model.service.ConnectMySQL

package model.service;import java.sql.DriverManager;
import java.sql.SQLException;import model.dao.MySQL;public class ConnectMySQL {//加载驱动public static void LoadDriver(String JDBCNAME) {try {Class.forName(JDBCNAME);System.out.println("加载数据成功");}catch(Exception e) {System.out.println("加载数据失败");}}//连接数据库public static void LoadConnect(String URL, String ACCOUNT, String PASSWORD) {try {MySQL.con = DriverManager.getConnection(URL,ACCOUNT,PASSWORD);System.out.println("连接数据库成功");}catch(SQLException e) {System.out.println("连接数据库失败");}}
}

model.service.DeleteMySQL

package model.service;import java.sql.PreparedStatement;
import java.sql.SQLException;import javax.swing.JOptionPane;import model.dao.MySQL;
import view.ui.StudentSystem;public class DeleteMySQL {public static void DeleteMethod(String URI, String key) {try {PreparedStatement preSql;preSql = MySQL.con.prepareStatement(URI);preSql.setString(1, key);preSql.executeUpdate();JOptionPane.showMessageDialog(null, "删除成功", "删除数据",JOptionPane.WARNING_MESSAGE);StudentSystem.delete.dispose();}catch(SQLException e) {}}
}

model.service.OtherMySQL

package model.service;import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;import model.dao.MySQL;public class OtherMySQL {//判断账号密码是否存在于数据库中public static boolean CompareMethod(String URI, String account, String password) {Statement sql;ResultSet rs;try {sql = MySQL.con.createStatement();rs=sql.executeQuery(URI);while(rs.next()) {String acc=rs.getString(1);//返回的第一个值就是账号String pass=rs.getString(2);//返回的第一个值就是账号if(acc.equals(account)&&pass.equals(password)){return true;}}}catch(SQLException e) {            return false;}return false;}
}

model.service.ShowMySQL

package model.service;import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;import controller.activity.ActionEvents;
import controller.service.ManageAppFrameMethod;
import model.dao.MySQL;
import view.ui.ManageAppFrame;public class ShowMySQL {public static void ShowAllMethod(String URI) {ManageAppFrame.model.setNumRows(0);//将表格数据为0try {PreparedStatement preSql;preSql = MySQL.con.prepareStatement(URI);ResultSet rs = preSql.executeQuery();ManageAppFrameMethod.AddTable(rs);}catch(SQLException e) {System.out.println(e);}}public static void ShowConMethod(String URI, String name, String sex, String age, String grade, String number) {ManageAppFrame.model.setNumRows(0);//将表格数据为0try {PreparedStatement preSql;ResultSet count = null ;preSql = MySQL.con.prepareStatement(URI);preSql.setString(1, name);preSql.setString(2, sex);preSql.setString(3, age);preSql.setString(4, grade);preSql.setString(5, number);count = preSql.executeQuery();ManageAppFrameMethod.AddTable(count);}catch(SQLException e) {System.out.println(e);}}public static void ShowOneMethod(String URI, String key) {try {PreparedStatement preSql;ResultSet count = null ;preSql = MySQL.con.prepareStatement(URI);preSql.setString(1, key);count = preSql.executeQuery();ActionEvents.addOneAble(count);}catch(SQLException e) {System.out.println(e);}}
}

Java课设之Swing学生信息管理系统(源码)相关推荐

  1. java计算机毕业设计基于Ssm学生信息管理系统源码+数据库+系统+lw文档+mybatis+运行部署

    java计算机毕业设计基于Ssm学生信息管理系统源码+数据库+系统+lw文档+mybatis+运行部署 java计算机毕业设计基于Ssm学生信息管理系统源码+数据库+系统+lw文档+mybatis+运 ...

  2. java毕业设计普通中学体育卫生信息管理系统源码+lw文档+mybatis+系统+mysql数据库+调试

    java毕业设计普通中学体育卫生信息管理系统源码+lw文档+mybatis+系统+mysql数据库+调试 java毕业设计普通中学体育卫生信息管理系统源码+lw文档+mybatis+系统+mysql数 ...

  3. java计算机毕业设计进出口食品安全信息管理系统源码+mysql数据库+系统+lw文档+部署

    java计算机毕业设计进出口食品安全信息管理系统源码+mysql数据库+系统+lw文档+部署 java计算机毕业设计进出口食品安全信息管理系统源码+mysql数据库+系统+lw文档+部署 本源码技术栈 ...

  4. Java学生信息管理系统源码

    学生信息管理系统 功能说明 学生信息管理,包括学生.班级.院系.课程.成绩等的管理. 本程序仅供学习食用. 工程环境 JDK IntelliJ IDEA MySQL 运行说明 1.安装JDK. 2.导 ...

  5. Javaweb学生信息管理系统(源码)

                              关注微信公众号:小诸葛的博客 回复101获取项目源码 1.项目名称:学生成绩管理系统 主要管理学生信息及成绩.教师信息.考试信息等. 2.系统环境: ...

  6. 原生php开发学生信息管理系统源码

    主要功能: 1.班级管理 (1)添加班级:输入班级名称,选择系别,确认添加 (2)班级列表:班级列表显示,班级修改,删除班级,列表分页 2.学生管理 (1)添加学生:输入学生姓名,选择系别,选择班级名 ...

  7. java课设--简单的学生成绩管理系统(可视化界面,连接MYsql数据库)

    1.登录界面 package kk;import java.awt.BorderLayout; import java.awt.EventQueue;import javax.swing.JFrame ...

  8. JAVA课设作业-实现饭店点菜系统源码

    JAVA实现饭店点菜系统详解-增强健壮性 原文: JAVA实现饭店点菜系统详解. 本文在上文的基础上增强了代码的健壮性和其他一些修改.如有bug还请各位积极指正,共同成长! 话不多说,码来: pack ...

  9. 基于SpringBoot医院信息管理系统源码

    hisystem 1. 用idea打开项目,并且配置maven下载依赖 2. 导入数据库 hisystem.sql 3. 修改application.yml数据库相关配置 4. 用户注册,验证邮件的邮 ...

最新文章

  1. 006_Gson定制型适配器
  2. hbuilder设置html浏览器打开,HBuilder X如何配置浏览器操作配置方法
  3. 游戏开发之nullptr和的NULL的区别(C++基础)
  4. Atitit 如何设置与安放知识的trap陷阱  知识聚合 rss url聚合工具 以及与trap的对比
  5. 包含的前缀数目超过了最大值。最大值为 2_「西法带你学算法」一次搞定前缀和...
  6. python库手册(官方)python文档
  7. 2021 年推荐免费网络托管免费空间提供商
  8. FirefoxOS 系统进程初步分析 底层系统继承自 android
  9. ff14服务器延迟滑步,ff14 5.0黑魔怎么玩_最终幻想14 5.0黑魔输出手法
  10. 关于google地图的一些使用
  11. 软考中级选哪个比较合适?
  12. pytorch Module里的children()与modules()的区别
  13. AI每日小练习之磨砂玻璃质感图标
  14. 读取txt的中文字符出现乱码的解决方法
  15. opencv Canny算子
  16. 我是如何一步一步搞定小区的安防系统
  17. FCPX插件直接导入OBJ三维模型FCPX3D MODEL
  18. 微型计算机软件主要包括什么,系统软件主要包括哪几个部分?
  19. 鸿蒙os升级时间表,鸿蒙os2.0系统升级了什么_鸿蒙os2.0系统升级内容
  20. FL Studio21水果体验尝鲜版音乐宿主程序FL2023

热门文章

  1. 基于ARM的LCD(800*480)触摸屏实现音频、视频播放、图像显示功能
  2. Oracle exists 用法
  3. 什么是操作系统?操作系统的作用和主流的操作系统有哪些(详)
  4. 广州某科技公司面试题 ——wang
  5. python按钮调用函数_Python中Button组件的属性及参数
  6. 工作VS生活:要融合,不要平衡
  7. JS十大取整方法解说
  8. 安装vmware虚拟机fedora
  9. “想象之中”,【玉石雕刻刀】的神奇之处
  10. iOS 硬件 导航 - 系统请求数据 绘制路线