基于java的Swing+MySQL学生管理系统java基础gui(java+gui)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

242123520307

380123062402

基于java的Swing+MySQL学生管理系统java基础gui(java+gui)

功能介绍:

学生信息管理,姓名,编号,性别,成绩,学号住址

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

/**
* 重置事件处理
* @param evt
*/
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;


/**
* Create the frame.
*/
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://yms-1257401191.cos.ap-nanjing.myqcloud.com/bookTypeManager.png")));
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://yms-1257401191.cos.ap-nanjing.myqcloud.com/add.png")));
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://yms-1257401191.cos.ap-nanjing.myqcloud.com/edit.png")));
mnNewMenu_1.add(menuItem_1);

JMenu mnNewMenu_2 = new JMenu("学生信息管理");
mnNewMenu_2.setIcon(new ImageIcon(MainFrm.class.getResourcehttps://yms-1257401191.cos.ap-nanjing.myqcloud.com/bookManager.png")));
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://yms-1257401191.cos.ap-nanjing.myqcloud.com/add.png")));
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://yms-1257401191.cos.ap-nanjing.myqcloud.com/artisan.png")));
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();
// TODO Auto-generated constructor stub
}

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) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("数据库连接失败");
}
}

}
package com.artisan.view;



public class ArtisanInterFrm extends JInternalFrame {


/**
* Create the frame.
*/
public ArtisanInterFrm() {
//getContentPane().setBackground(Color.RED);
setIconifiable(true);
setClosable(true);
setTitle("关于系统");
setBounds(100, 100, 450, 300);

JLabel lblNewLabel = new JLabel("");
lblNewLabel.setIcon(new ImageIcon(ArtisanInterFrm.class.getResourcehttps://yms-1257401191.cos.ap-nanjing.myqcloud.com/artisan.png")));
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();
}

/**
* 学生信息查询
* @param con
* @param student
* @return
* @throws Exception
*/
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();
}

/**
* 学生信息删除
* @param con
* @param id
* @return
* @throws Exception
*/
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);

// 设置JFrame居中显示
this.setLocationRelativeTo(null);
}

/**
* 登录事件处理
* @param e
*/
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 {


项目链接:
https://javayms.github.io?id=061222062008200wg
https://javayms.pages.dev?id=061222062008200wg