——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明


基于java的Swing+MySQL学生管理系统java基础gui(java+gui)
功能介绍:
学生信息管理,姓名,编号,性别,成绩,学号住址
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
private void resetValueActionPerformed(ActionEvent evt) { this.resetValue(); }
private void resetValue(){ this.classNameTxt.setText(""); this.classDescTxt.setText(""); } } package com.artisan.view;
public class MainFrm extends JFrame {
private JPanel contentPane; private JDesktopPane table =null;
public MainFrm() { setTitle("学生信息管理系统主界面"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 450, 300); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnNewMenu = new JMenu("基本数据维护");
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| JMenu mnNewMenu_1 = new JMenu("班级信息管理"); mnNewMenu_1.setIcon(new ImageIcon(MainFrm.class.getResourcehttps: mnNewMenu.add(mnNewMenu_1);
JMenuItem menuItem = new JMenuItem("班级信息添加"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { SchoolClassAddInterFrm bookTypeAddInterFrm=new SchoolClassAddInterFrm(); bookTypeAddInterFrm.setVisible(true); table.add(bookTypeAddInterFrm); } }); menuItem.setIcon(new ImageIcon(MainFrm.class.getResourcehttps: mnNewMenu_1.add(menuItem);
JMenuItem menuItem_1 = new JMenuItem("班级信息整改"); menuItem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { SchoolClassManageInterFrm bookTypeManageInterFrm=new SchoolClassManageInterFrm(); bookTypeManageInterFrm.setVisible(true); table.add(bookTypeManageInterFrm); } }); menuItem_1.setIcon(new ImageIcon(MainFrm.class.getResourcehttps: mnNewMenu_1.add(menuItem_1);
JMenu mnNewMenu_2 = new JMenu("学生信息管理"); mnNewMenu_2.setIcon(new ImageIcon(MainFrm.class.getResourcehttps: mnNewMenu.add(mnNewMenu_2);
JMenuItem menuItem_2 = new JMenuItem("学生信息添加"); menuItem_2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { StudentAddInterFrm bookAddInterFrm=new StudentAddInterFrm(); bookAddInterFrm.setVisible(true); table.add(bookAddInterFrm); } });
menuItem_2.setIcon(new ImageIcon(MainFrm.class.getResourcehttps: mnNewMenu_2.add(menuItem_2);
JMenuItem menuItem_3 = new JMenuItem("学生信息整改"); menuItem_3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { StudentManageInterFrm bookManageInterFrm=new StudentManageInterFrm();
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| setClosable(true); setTitle("关于系统"); setBounds(100, 100, 450, 300); JLabel lblNewLabel = new JLabel(""); lblNewLabel.setIcon(new ImageIcon(ArtisanInterFrm.class.getResourcehttps: GroupLayout groupLayout = new GroupLayout(getContentPane()); groupLayout.setHorizontalGroup( groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup() .addGap(98) .addComponent(lblNewLabel) .addContainerGap(126, Short.MAX_VALUE)) ); groupLayout.setVerticalGroup( groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup() .addGap(48) .addComponent(lblNewLabel) .addContainerGap(149, Short.MAX_VALUE)) ); getContentPane().setLayout(groupLayout);
} } package com.artisan.model;
public class SchoolClass {
private int id; private String className; private String calssDesc; public SchoolClass() { super(); }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| if (con != null) { con.close(); } }
public static void main(String[] args) { DbUtil dbUtil = new DbUtil(); try { dbUtil.getCon(); System.out.println("数据库连接成功!"); } catch (Exception e) { e.printStackTrace(); System.out.println("数据库连接失败"); } }
} package com.artisan.view;
public class ArtisanInterFrm extends JInternalFrame {
public ArtisanInterFrm() { setIconifiable(true); setClosable(true); setTitle("关于系统"); setBounds(100, 100, 450, 300); JLabel lblNewLabel = new JLabel(""); lblNewLabel.setIcon(new ImageIcon(ArtisanInterFrm.class.getResourcehttps: GroupLayout groupLayout = new GroupLayout(getContentPane()); groupLayout.setHorizontalGroup( groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup() .addGap(98) .addComponent(lblNewLabel)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| pstmt.setString(3, student.getSex()); pstmt.setString(4, student.getDept()); pstmt.setInt(5, student.getClassId()); pstmt.setString(6, student.getAddress()); return pstmt.executeUpdate(); }
public ResultSet list(Connection con,Student student)throws Exception{ StringBuffer sb=new StringBuffer("select * from t_student b,t_school_class bt where b.classId=bt.id"); if(StringUtil.isNotEmpty(student.getName())){ sb.append(" and b.name like '%"+student.getName()+"%'"); } if(StringUtil.isNotEmpty(student.getSn())){ sb.append(" and b.sn like '%"+student.getSn()+"%'"); } if(student.getClassId()!=null && student.getClassId()!=-1){ sb.append(" and b.classId="+student.getClassId()); } PreparedStatement pstmt=con.prepareStatement(sb.toString()); return pstmt.executeQuery(); }
public int delete(Connection con,String id)throws Exception{ String sql="delete from t_student where id=?"; PreparedStatement pstmt=con.prepareStatement(sql); pstmt.setString(1, id); return pstmt.executeUpdate();
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| gl_contentPane.setVerticalGroup( gl_contentPane.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPane.createSequentialGroup() .addGap(30) .addComponent(lblNewLabel) .addGap(26) .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPane.createSequentialGroup() .addComponent(lblNewLabel_1) .addGap(29) .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE) .addComponent(lblNewLabel_2) .addComponent(passwordTxt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addComponent(userNameTxt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(36) .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE) .addComponent(btnNewButton) .addComponent(btnNewButton_1)) .addContainerGap(60, Short.MAX_VALUE)) ); contentPane.setLayout(gl_contentPane); this.setLocationRelativeTo(null); }
private void loginActionPerformed(ActionEvent evt) { String userName=this.userNameTxt.getText(); String password=new String(this.passwordTxt.getPassword()); if(StringUtil.isEmpty(userName)){ JOptionPane.showMessageDialog(null, "用户名不能为空!"); return; } if(StringUtil.isEmpty(password)){ JOptionPane.showMessageDialog(null, "密码不能为空!"); return; } User user=new User(userName,password); Connection con=null; try {
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=061222062008200wg
https://javayms.pages.dev?id=061222062008200wg