简述:做这个系统的时候因为时间不是很多

所以调用了一些网上的界面,直接拿了过来改了下人家的JFrame

话不多说,代码如下

连接时注意jdk版本问题

一,连接与核心查询类代码

package daoru;

import java.sql.*;

import javax.swing.JOptionPane;
import javax.swing.Spring;

//数据库连接程序
public class MysqlConn {
	public static String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
    public static String dbURL="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=学生成绩管理系统";
    public static String userName="sa";
    public static String userPwd="123456789";
	
	//设定用户名和密码
    public static String userword;
    public static String pawd;
	
    //修改或者插入学生信息类时使用的变量
    public static String cname = null;
    public static String cno = null;
    public static String stucredit = null;
    
    //设定学生账户的信息类   
    public static String stuid = null;
    public static String stuname = null;
    public static String stusex = null;
    public static String stunj=null;
    public static String stuzy=null;
	
   
   
    //计学生人数的变量
	public static int counter = 0;
	
	//学生个人信息的
	public static String [] stu_sno = new String[10];
	public static String [] stu_name = new String[10];
	public static String [] stu_sex = new String[10];
	public static String [] stu_zy = new String[10];
	public static String [] stu_nj = new String[10];
	
	//统计分数的
	public static String [] stu_kcbh = new String[10];
	public static String [] stu_kcmc = new String[10];
	public static double [] stu_point = new double[10];
	
	
	//课程表类
	public static String [] c_no = new String[10];
	public static String [] ct_name = new String[10];
	public static String [] c_name = new String[10];
	public static String [] c_rkjs=new String[10];
	public static double [] credit = new double[10];
	
	//执行sql语句与返回sql执行结果
	public static Connection conn = null;
	public static PreparedStatement ps = null;
	public static ResultSet rs = null;
	
	//连接数据库
	public static void ConnectSQL() {
		try {
    		 Class.forName(driverName);
	         conn=DriverManager.getConnection(dbURL,userName,userPwd);//即验证数据库的账号与密码进行连接
			System.out.println("The SQL is connected");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	// 判断用户是否存在
	//判断管理员的id是否存在
	public static boolean queryadm(String id) {
		// 创建火箭车
		try {
			ps = conn.prepareStatement("select * from gly where ID = ?");
			ps.setString(1, id);
			// ResultSet结果集把ResultSet理解成返回一张表行的结果集
			rs = ps.executeQuery();
			if (rs.next()) {//即返回一张表中的所有密码
				pawd = rs.getString("password");
				return true;
			}
		} catch (Exception e1) {
			
			e1.printStackTrace();
		}
		return false;
	}
	
	//判断该学生的学号是否存在
	public static boolean querystu(String id) {
		try {
			ps = conn.prepareStatement("select * from Student where sno = ?");
			ps.setString(1, id);
			rs = ps.executeQuery();
			if (rs.next()) {
				pawd = rs.getString("sno");
				return true;
			}
		} catch (Exception e1) {
		
			e1.printStackTrace();//查看错误信息的代码
		}
		return false;
	}
	
	
	public static void getdatastu() {
		try {
			ps = conn.prepareStatement("select * from Student");
			rs = ps.executeQuery();
			counter = 0;
			while(rs.next())	
			{
				stu_sno[counter] = rs.getString("sno");//学号
				stu_name[counter] = rs.getString("sname");//姓名
				stu_sex[counter] = rs.getString("sex");//性别-->即如果用的是String类型就不能用date类型否则会返回不了所需要的值
				stu_zy[counter] = rs.getString("zy");//专业
				stu_nj[counter] = rs.getString("nj");//年级
				counter++;
			}
	
		} catch (Exception e1) {
			e1.printStackTrace();
		}
	}
//获取一个学生的成绩类信息-->对接student函数
	public static void getdatastu(String s) {
		
		try {
			ps = conn.prepareStatement("select * from Grade where sno = ?");
			ps.setString(1, s);
			rs = ps.executeQuery();
			counter = 0;
			while(rs.next())	
			{
				c_name[counter] = rs.getString("sno");
				stu_kcbh[counter] = rs.getString("kcbh");
				stu_kcmc[counter] = rs.getString("kcmc");
				stu_point[counter] = rs.getDouble("fs");
				counter++;
			}
	
		} catch (Exception e1) {
			e1.printStackTrace();
		}
	}
	//获取所有学生的个人成绩信息
	public static void getdatagra() {
		try {
			ps = conn.prepareStatement("select * from Grade where Grade.sno in (select sno from Student)");
			rs = ps.executeQuery();
			
			counter = 0;
			while(rs.next())	
			{
				c_name[counter] = rs.getString("sno");
				stu_kcbh[counter] = rs.getString("kcbh");
				stu_kcmc[counter] = rs.getString("kcmc");
				stu_point[counter] = rs.getDouble("fs");
				counter++;
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	

	
	//增加学生-->有小bug
	public static void insertstu() {
		try{
			ps = conn.prepareStatement("insert into Student values ('"+stuid+"','"+stuname+"','"+stusex+"','"+stunj+"','"+stuzy+"')");
			ps.executeUpdate();
			
			JOptionPane.showMessageDialog(null, "学生记录添加成功!", "提示消息", JOptionPane.INFORMATION_MESSAGE);
				
		} catch (Exception e1) {
			
			JOptionPane.showMessageDialog(null, "数据添加异常!", "提示消息", JOptionPane.ERROR_MESSAGE);
			e1.printStackTrace();
		}
		
	}

	public static void deletestu(String stuid2) {
		try {
			ps = conn.prepareStatement("delete from Student where sno = ? ");
			ps.setString(1, stuid2);
			ps.execute();
			
			JOptionPane.showMessageDialog(null, "学生记录删除成功!", "提示消息", JOptionPane.INFORMATION_MESSAGE);
			
		} catch (Exception e1){
			
			JOptionPane.showMessageDialog(null, "数据删除失败!", "提示消息", JOptionPane.ERROR_MESSAGE);
			e1.printStackTrace();
		}
	}

	




	

	

	public static void getdatacou() {
		try {
			ps = conn.prepareStatement("select * from Course ");
			rs = ps.executeQuery();
			counter = 0;
			while(rs.next()){
				c_no[counter] = rs.getString("kcbh");
				c_name[counter] = rs.getString("kcm");
				c_rkjs[counter] = rs.getString("rkjs");
				counter++;
			}
			
		}catch (Exception e){
			e.printStackTrace();
		}
	}
//查询课程函数对接功能实现
	public static boolean querycou(String text) {
		try {
			ps = conn.prepareStatement("select kcbh from Course where kcbh = ?");
			ps.setString(1, text);
			rs = ps.executeQuery();
			if(rs.next()){
				return true;
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return false;
	}
//插入课表对接函数
	public static void insertcou(String cno2, String cname2, String stucredit2) {
		try{
			ps = conn.prepareStatement("insert into Course values ('"+ cno2 +"','"+ cname2 +"','"+stucredit2+"')");
			ps.executeUpdate();
			
			JOptionPane.showMessageDialog(null, "课程信息添加成功!", "提示消息", JOptionPane.INFORMATION_MESSAGE);
		}catch(Exception e){
			e.printStackTrace();
			JOptionPane.showMessageDialog(null, "课程信息添加失败!", "提示消息", JOptionPane.INFORMATION_MESSAGE);
		}
	}

	

	public static void deletecou(String cno2) {
		try {
			ps = conn.prepareStatement("delete from Course where kcbh = ?");
			ps.setString(1, cno2);
			ps.execute();
			
			JOptionPane.showMessageDialog(null, "课程删除成功!", "提示消息", JOptionPane.INFORMATION_MESSAGE);
		}catch(Exception e){
			e.printStackTrace();
			JOptionPane.showMessageDialog(null, "课程删除失败!", "提示消息", JOptionPane.INFORMATION_MESSAGE);
		}
	}

	public static void getdatacou(String cname2) {
		try {
			ps = conn.prepareStatement("select Cno from 课程 where Cname = ?");
			ps.setString(1, cname2);
			rs = ps.executeQuery();
			
			if(rs.next()){
				cno = rs.getString("Cno");
			}
			
		}catch (Exception e){
			e.printStackTrace();
		}
	}
}

二,界面类代码

①Admin.java管理员界面

//管理员选择学生还是课程的界面
package SMIS;

import java.awt.event.*;

import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.GroupLayout.Alignment;
import java.awt.Font;
import ui.Login;

//查询、更新学生信息
public class Admin extends JFrame {
	JButton jb1,jb2 = null;
	JRadioButton jrb1,jrb2 = null;
	JLabel jl = null;
	JPanel jp = null;
	ButtonGroup bg = null;
	
	public Admin() {
		getContentPane().setLayout(null);
		
		jp = new JPanel();
		jp.setBounds(125, 184, 386, 190);
		getContentPane().add(jp);
		jp.setLayout(null);
		
		jl = new JLabel("操作对象");
		jl.setBounds(29, 48, 60, 37);
		jp.add(jl);
		
		jrb1 = new JRadioButton("学生");//学生
		jrb1.setBounds(118, 48, 59, 37);
		jp.add(jrb1);
		
		bg = new ButtonGroup();
		bg.add(jrb1);
		bg.add(jrb2);
		
		jb1 = new JButton("确定");
		jb1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
				if(jrb1.isSelected()){
					Stu st = new Stu();
				}
				else{
					Cou co = new Cou();
				}
			}
		});
		jb1.setBounds(41, 109, 72, 42);
		jp.add(jb1);
		

		JButton jb2 = new JButton("退出");
		jb2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		jb2.setBounds(267, 109, 76, 42);
		jp.add(jb2);
		
		JRadioButton radioButton = new JRadioButton("课程");
		radioButton.setBounds(206, 48, 59, 37);
		jp.add(radioButton);
		bg.add(radioButton);
		
		JButton button = new JButton("返回");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
				Login l = new Login();
			}
		});
		button.setBounds(154, 109, 72, 42);
		jp.add(button);
		
		JLabel label = new JLabel("欢迎登录学生成绩管理系统!");
		label.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 46));
		label.setBounds(14, 55, 604, 60);
		getContentPane().add(label);
		
		//给窗口设置标题
		this.setTitle("学生成绩管理系统-管理员");
		//设置窗体大小
		this.setSize(650,520);
		//设置窗体初始位置
		this.setLocation(200, 150);
		//设置当关闭窗口时,保证JVM也退出
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//显示窗体
		this.setVisible(true);
		//窗体大小可变
		this.setResizable(true);
	}
}

②COU.java

//课程界面类
package SMIS;

import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import daoru.MysqlConn;
import SMIS.Admin;
import SMIS.Cou;
import gn.InsertCou;
import gn.InsertStu;
import gn.Delete;
import gn.QueryCou;
import gn.QueryStu;
import gn.JudgeNum;//统计数目功能
import SMIS.Stu;
import SMIS.Student;

public class Cou extends JFrame {
	public Cou() {
		getContentPane().setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBounds(152, 59, 329, 302);
		getContentPane().add(panel);
		panel.setLayout(null);
		
		JLabel label = new JLabel("请选择您要进行的操作");
		label.setBounds(69, 5, 191, 41);
		panel.add(label);
		label.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		
		JButton button = new JButton("查询课程信息");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
				QueryCou qc = new QueryCou();
			}
		});
		button.setBounds(94, 59, 140, 47);
		panel.add(button);
		
		JButton button_1 = new JButton("添加课程信息");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
				InsertCou ic = new InsertCou();
			}
		});
		button_1.setBounds(94, 119, 140, 47);
		panel.add(button_1);
		
		JButton button_3 = new JButton("删除课程信息");
		button_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
				Delete dc = new Delete();
			}
		});
		button_3.setBounds(94, 182, 140, 47);
		panel.add(button_3);
		
		JButton button_4 = new JButton("返回");
		button_4.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
				Admin ad = new Admin();
			}
		});
		button_4.setBounds(202, 389, 94, 41);
		getContentPane().add(button_4);
		
		JButton button_5 = new JButton("退出");
		button_5.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		button_5.setBounds(345, 389, 94, 41);
		getContentPane().add(button_5);
		
		//给窗口设置标题
		this.setTitle("学生信息管理系统-管理员");
		//设置窗体大小
		this.setSize(650,520);
		//设置窗体初始位置
		this.setLocation(200, 150);
		//设置当关闭窗口时,保证JVM也退出
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//显示窗体
		this.setVisible(true);
		//窗体大小可变
		this.setResizable(true);
	}
}

③Stu.java

//管理员管理的学生界面类
package SMIS;

import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import SMIS.Admin;
import SMIS.Cou;
import gn.InsertCou;
import gn.InsertStu;
import gn.Delete;
import gn.QueryCou;
import gn.QueryStu;
import gn.JudgeNum;//统计数目功能



//查询、插入、修改、删除学生信息
public class Stu extends JFrame{
	public Stu() {
		getContentPane().setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBounds(151, 27, 330, 305);
		getContentPane().add(panel);
		panel.setLayout(null);
		
		JLabel label = new JLabel("请选择您要进行的操作");
		label.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		label.setBounds(69, 13, 191, 41);
		panel.add(label);
		
		JButton button = new JButton("查询学生信息");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
				QueryStu qs = new QueryStu();
			}
		});
		button.setBounds(91, 67, 143, 50);
		panel.add(button);
		
		JButton button_1 = new JButton("添加学生信息");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
				InsertStu is = new InsertStu();
			}
		});
		button_1.setBounds(91, 128, 143, 50);
		panel.add(button_1);
		
		
		
		JButton button_3 = new JButton("删除学生信息");
		button_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
				Delete ds = new Delete();
			}
		});
		button_3.setBounds(91, 185, 143, 50);
		panel.add(button_3);
		
		JPanel panel_1 = new JPanel();
		panel_1.setBounds(179, 367, 272, 49);
		getContentPane().add(panel_1);
		panel_1.setLayout(null);
		
		JButton button_4 = new JButton("返回");
		button_4.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
				Admin ad = new Admin();
			}
		});
		button_4.setBounds(41, 5, 76, 40);
		panel_1.add(button_4);
		
		JButton button_5 = new JButton("退出");
		button_5.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		button_5.setBounds(146, 5, 76, 40);
		panel_1.add(button_5);
		
		//给窗口设置标题
		this.setTitle("学生信息管理系统-管理员");
		//设置窗体大小
		this.setSize(650,520);
		//设置窗体初始位置
		this.setLocation(200, 150);
		//设置当关闭窗口时,保证JVM也退出
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//显示窗体
		this.setVisible(true);
		//窗体大小可变
		this.setResizable(true);
	}
}

④Student.java

package SMIS;

import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.BorderLayout;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextArea;
import javax.swing.JFormattedTextField;
import daoru.MysqlConn;
import SMIS.Admin;
import SMIS.Cou;
import gn.InsertCou;
import gn.InsertStu;

import gn.Delete;
import gn.QueryCou;
import gn.QueryStu;
import gn.JudgeNum;//统计数目功能
import ui.Login;


public class Student extends JFrame {
	private JTable table;
	public Student() {
		getContentPane().setLayout(null);
		
		JButton btnNewButton = new JButton("查成绩");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				MysqlConn.ConnectSQL();
				MysqlConn.getdatastu(MysqlConn.userword);
				
				for(int i = 0; i < MysqlConn.counter; i++){
					table.setValueAt(MysqlConn.c_name[i], i, 0);
					table.setValueAt(MysqlConn.stu_kcbh[i], i, 1);
					table.setValueAt(MysqlConn.stu_kcmc[i], i, 2);
					table.setValueAt(MysqlConn.stu_point[i], i, 3);
				}
				
			}
		});
		btnNewButton.setBounds(161, 162, 97, 37);
		getContentPane().add(btnNewButton);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(39, 212, 560, 152);
		getContentPane().add(scrollPane);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
			},
			new String[] {
				"学号", "课程编号", "课程名称", "分数"
			}
		));
		table.setRowHeight(30);
		scrollPane.setViewportView(table);
		
		
		
		JButton button = new JButton("退出");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		button.setBounds(383, 162, 97, 37);
		getContentPane().add(button);
		
		JLabel label_4 = new JLabel("欢迎登录学生成绩管理系统");
		label_4.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 46));
		label_4.setBounds(14, 29, 604, 117);
		getContentPane().add(label_4);
		
		JButton button_1 = new JButton("返回");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
				Login l = new Login();
			}
		});
		button_1.setBounds(272, 162, 97, 37);
		getContentPane().add(button_1);
		
		this.setTitle("学生成绩管理系统-学生");
		//设置窗体大小
		this.setSize(650,520);
		//设置窗体初始位置
		this.setLocation(200, 150);
		//设置当关闭窗口时,保证JVM也退出
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//显示窗体
		this.setVisible(true);
		//窗体大小可变
		this.setResizable(true);
	}
}

三,UI界面

Login.java

//登录界面类
package ui;

import java.awt.*;//提供GUI的设计工具
import java.awt.event.*;//提供awt组件事件的监听以及相应
import javax.swing.*;//配置选定功能的实现与框架功能
import daoru.MysqlConn;
import SMIS.Admin;
import SMIS.Cou;
import gn.InsertCou;
import gn.InsertStu;
import gn.Delete;
import gn.QueryCou;
import gn.QueryStu;
import gn.JudgeNum;//统计数目功能
import SMIS.Stu;
import SMIS.Student;



public class Login extends JFrame implements ActionListener {

	//定义登录界面的组件
	JButton jb1,jb2,jb3=null;
	JRadioButton jrb1,jrb2,jrb3=null;
	JPanel jp4=null;
    JTextField jtf=null;
	JLabel jlb1,jlb2,jlb3=null;
	JPasswordField jpf=null;
	ButtonGroup bg=null;	
	
	public static void main(String[] args) {
		Login ms=new Login();	
	}
	//构造函数
	public Login()
	{
		bg=new ButtonGroup();
		jp4=new JPanel();
		jp4.setBounds(0, 0, 0, 0);
		getContentPane().setLayout(null);
		getContentPane().add(jp4);
		
		jlb1=new JLabel("用户名:");
		jlb1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		jlb1.setBounds(181, 92, 83, 37);//x,y,width,height
		getContentPane().add(jlb1);
		
		jtf=new JTextField(12);
		jtf.setBounds(265, 92, 133, 37);
		getContentPane().add(jtf);
		
		jlb2=new JLabel("密    码:");
		jlb2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		jlb2.setBounds(181, 161, 83, 37);
		getContentPane().add(jlb2);
		
		jpf = new JPasswordField(12);
		jpf.setBounds(265, 161, 133, 37);
		getContentPane().add(jpf);
		
		jlb3=new JLabel("权    限:");
		jlb3.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		jlb3.setBounds(181, 227, 83, 37);
		getContentPane().add(jlb3);
		
		jrb1=new JRadioButton("管理员");
		jrb1.setBounds(265, 227, 73, 37);
		getContentPane().add(jrb1);
		bg.add(jrb1);
		
		jrb3=new JRadioButton("学生",true);
		jrb3.setBounds(349, 227, 59, 37);
		getContentPane().add(jrb3);
		bg.add(jrb3);
		
		jb1=new JButton("登录");
		jb1.setBounds(181, 311, 76, 40);
		getContentPane().add(jb1);
		jb2=new JButton("重置");
		jb2.setBounds(265, 311, 76, 40);
		getContentPane().add(jb2);
		jb3=new JButton("退出");
		jb3.setBounds(349, 311, 76, 40);
		getContentPane().add(jb3);
		jb3.addActionListener(this);//退出键的监听
		jb2.addActionListener(this);//重置的监听
		//设置监听
		jb1.addActionListener(this);//登录的监听实现
		//给窗口设置标题
		this.setTitle("学生成绩管理系统-登录");
		//设置窗体大小
		this.setSize(650,520);
		//设置窗体初始位置
		this.setLocation(200, 150);
		//设置当关闭窗口时,保证JVM也退出
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//显示窗体
		this.setVisible(true);
		//窗体大小可变
		this.setResizable(true);
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {

		if(e.getActionCommand()=="退出")
		{
			System.exit(0);
		}else if(e.getActionCommand()=="登录")
		{
			if(!jtf.getText().isEmpty() && !String.valueOf(jpf.getPassword()).isEmpty())
			{
				
				MysqlConn.ConnectSQL();
				if(jrb1.isSelected())//选择管理员进行登录
				{
					if(MysqlConn.queryadm(jtf.getText()))
					{
						this.adminlogin();//调用这个里面的adminlogin函数
					}
				}else if(jrb3.isSelected())//选择学生进行登录
				{
					
					if(MysqlConn.querystu(jtf.getText()))
					{
						MysqlConn.userword = jtf.getText();
						
						this.stulogin();
					}
				}
			}else if(jtf.getText().isEmpty())//即没有输入进行输入的状况提示
			{
				JOptionPane.showMessageDialog(null,"请输入用户名","提示消息",JOptionPane.WARNING_MESSAGE);
			    this.clear();
			}else if(String.valueOf(jpf.getPassword()).isEmpty())	
			{
				JOptionPane.showMessageDialog(null,"请输入密码","提示消息",JOptionPane.WARNING_MESSAGE);
			    this.clear();
			}
		}else if(e.getActionCommand()=="重置")
		{
			this.clear();
		}			
	}
	
	//清空文本框和密码框
	public void clear()
	{
		jtf.setText("");
		jpf.setText("");
	}
	
	//管理员登录
	public void adminlogin(){
		if(MysqlConn.pawd.equals(String.valueOf(jpf.getPassword())))
		{
			JOptionPane.showMessageDialog(null,"登录成功!","提示消息",JOptionPane.WARNING_MESSAGE);
			this.clear();
			//关闭当前界面
			dispose();
			//创建一个新界面
			Admin ad=new Admin();
		}else if(jtf.getText().isEmpty()&&String.valueOf(jpf.getPassword()).isEmpty())
		{
			JOptionPane.showMessageDialog(null,"请输入用户名和密码!","提示消息",JOptionPane.WARNING_MESSAGE);
		}else if(jtf.getText().isEmpty())
		{
			JOptionPane.showMessageDialog(null,"请输入用户名!","提示消息",JOptionPane.WARNING_MESSAGE);
		}else if(String.valueOf(jpf.getPassword()).isEmpty())
		{
			JOptionPane.showMessageDialog(null,"请输入密码!","提示消息",JOptionPane.WARNING_MESSAGE);
		}else
		{
			JOptionPane.showMessageDialog(null,"用户名或者密码错误!\n请重新输入","提示消息",JOptionPane.ERROR_MESSAGE);
		    //清空输入框
			this.clear();
		}
	}
	
	
	//学生登录
	public void stulogin(){
		if(MysqlConn.pawd.equals(String.valueOf(jpf.getPassword())))
		{
			JOptionPane.showMessageDialog(null,"登录成功!","提示消息",JOptionPane.WARNING_MESSAGE);
			this.clear();
			//关闭当前界面
			dispose();
			//创建一个新界面
			Student stu = new Student();
		}else if(jtf.getText().isEmpty()&&String.valueOf(jpf.getPassword()).isEmpty())
		{
			JOptionPane.showMessageDialog(null,"请输入用户名和密码!","提示消息",JOptionPane.WARNING_MESSAGE);
		}else if(jtf.getText().isEmpty())
		{
			JOptionPane.showMessageDialog(null,"请输入用户名!","提示消息",JOptionPane.WARNING_MESSAGE);
		}else if(String.valueOf(jpf.getPassword()).isEmpty())
		{
			JOptionPane.showMessageDialog(null,"请输入密码!","提示消息",JOptionPane.WARNING_MESSAGE);
		}else
		{
			JOptionPane.showMessageDialog(null,"用户名或者密码错误!\n请重新输入","提示消息",JOptionPane.ERROR_MESSAGE);
		    //清空输入框
			this.clear();
		}
	}
}

四,功能

①Delete.java

//删除学号与课程号的类
package gn;

import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.GroupLayout.Alignment;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import daoru.MysqlConn;
import SMIS.Stu;
import SMIS.Student;
import SMIS.Admin;
import SMIS.Cou;

public class Delete extends JFrame {
	private JTextField textField;
	public Delete() {
		getContentPane().setLayout(null);
		JPanel panel = new JPanel();
		panel.setBounds(152, 103, 321, 162);
		getContentPane().add(panel);
		panel.setLayout(null);
		
		JLabel label = new JLabel("请输入要删除的学号/课程号:");
		label.setBounds(0, 5, 321, 37);
		panel.add(label);
		label.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		//定义文本框类
		textField = new JTextField();
		textField.setBounds(72, 66, 159, 32);
		panel.add(textField);
		textField.setColumns(10);
		//定义按钮类
		JRadioButton rdbtnNewRadioButton = new JRadioButton("学生");
		rdbtnNewRadioButton.setBounds(31, 107, 59, 37);
		panel.add(rdbtnNewRadioButton);
		
		
		
		ButtonGroup bg = new ButtonGroup();
		JRadioButton radioButton_1 = new JRadioButton("课程");
		radioButton_1.setBounds(121, 107, 59, 37);
		panel.add(radioButton_1);
		bg.add(radioButton_1);
		
		JPanel panel_1 = new JPanel();
		panel_1.setBounds(141, 302, 343, 52);
		getContentPane().add(panel_1);
		
		JButton button = new JButton("确定");
		button.setBounds(8, 5, 76, 40);
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				MysqlConn.ConnectSQL();
				if(textField.getText().isEmpty()){
					JOptionPane.showMessageDialog(null,"请输入学号或课程号!","提示消息",JOptionPane.WARNING_MESSAGE);
				}else if(!JudgeNum.judge(textField.getText(), textField.getText().length())){
					JOptionPane.showMessageDialog(null, "学号或课程号仅由数字组成,您输入的学号或课程号形式有误!\n请重新输入", "提示消息", JOptionPane.ERROR_MESSAGE);
				}else if(!rdbtnNewRadioButton.isSelected()&& !radioButton_1.isSelected()){
					JOptionPane.showMessageDialog(null,"请选择学生或课程!","提示消息",JOptionPane.WARNING_MESSAGE);
				}else if(rdbtnNewRadioButton.isSelected()){
					if(!MysqlConn.querystu(textField.getText())){
						JOptionPane.showMessageDialog(null,"您输入的学号有误!\n请重新输入","提示消息",JOptionPane.ERROR_MESSAGE);
					}else{
						int option = JOptionPane.showConfirmDialog(null, "您确定删除该学生吗?", "提示消息", JOptionPane.OK_CANCEL_OPTION);
						if(option == JOptionPane.OK_OPTION){
							MysqlConn.stuid = textField.getText();
							
							//执行删除操作
							MysqlConn.deletestu(MysqlConn.stuid);
						}else {
							textField.setText("");
						}
					}
				}else{
					if(!MysqlConn.querycou(textField.getText())){
						JOptionPane.showMessageDialog(null,"您输入的课程号有误!\n请重新输入","提示消息",JOptionPane.ERROR_MESSAGE);
					}else{
						int option = JOptionPane.showConfirmDialog(null, "您确定删除该课程吗?", "提示消息", JOptionPane.OK_CANCEL_OPTION);
						if(option == JOptionPane.OK_OPTION){
							MysqlConn.cno = textField.getText();
							MysqlConn.deletecou(MysqlConn.cno);
						}else {
							textField.setText("");
						}
					}
				}
			}
		});
		panel_1.setLayout(null);
		panel_1.add(button);
		
		JButton button_1 = new JButton("返回");
		button_1.setBounds(176, 5, 76, 40);
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
				Admin ad = new Admin();
			}
		});
		
		JButton button_2 = new JButton("重置");
		button_2.setBounds(92, 5, 76, 40);
		button_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				textField.setText("");
			}
		});
		panel_1.add(button_2);
		panel_1.add(button_1);
		
		JButton button_3 = new JButton("退出");
		button_3.setBounds(260, 5, 76, 40);
		button_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		panel_1.add(button_3);
		
		this.setTitle("学生成绩管理系统-管理员-删除学生/课程");
		//设置窗体大小
		this.setSize(650,520);
		//设置窗体初始位置
		this.setLocation(200, 150);
		//设置当关闭窗口时,保证JVM也退出
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//显示窗体
		this.setVisible(true);
		//窗体大小可变
		this.setResizable(true);
	}
}

②InsertCou.java

//插入课程类
package gn;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import daoru.MysqlConn;
import SMIS.Stu;
import SMIS.Student;
import SMIS.Admin;
import SMIS.Cou;


public class InsertCou extends JFrame {
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	public InsertCou() {
		getContentPane().setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBounds(134, 49, 379, 265);
		getContentPane().add(panel);
		panel.setLayout(null);
		
		JLabel label = new JLabel("请填写您要添加的课程信息:");
		label.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		label.setBounds(79, 14, 238, 36);
		panel.add(label);
		
		JLabel label_1 = new JLabel("课程号:");
		label_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		label_1.setBounds(104, 76, 77, 41);
		panel.add(label_1);
		
		textField = new JTextField();
		textField.setBounds(181, 80, 110, 34);
		panel.add(textField);
		textField.setColumns(10);
		
		JLabel label_2 = new JLabel("课程名:");
		label_2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		label_2.setBounds(105, 137, 77, 41);
		panel.add(label_2);
		
		textField_1 = new JTextField();
		textField_1.setColumns(10);
		textField_1.setBounds(180, 137, 110, 34);
		panel.add(textField_1);
		
		JLabel label_3 = new JLabel("任课教师:");
		label_3.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		label_3.setBounds(104, 199, 77, 41);
		panel.add(label_3);
		
		textField_2 = new JTextField();
		textField_2.setColumns(10);
		textField_2.setBounds(181, 201, 110, 34);
		panel.add(textField_2);
		
		JButton button = new JButton("确定");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				MysqlConn.ConnectSQL();
				if(textField.getText().isEmpty()){
					JOptionPane.showMessageDialog(null,"请输入课程号!", "提示消息", JOptionPane.WARNING_MESSAGE);
				}else if(!JudgeNum.judge(textField.getText(), textField.getText().length())){
					JOptionPane.showMessageDialog(null,"课程号仅由数字组成,您输入的课程号形式有误!\n请重新输入", "提示消息", JOptionPane.WARNING_MESSAGE);
				}else if(MysqlConn.querycou(textField.getText())){
					JOptionPane.showMessageDialog(null,"该课程已存在!\n请重新输入", "提示消息", JOptionPane.WARNING_MESSAGE);
				}else if(textField_1.getText().isEmpty()){
					JOptionPane.showMessageDialog(null,"请输入课程名!", "提示消息", JOptionPane.WARNING_MESSAGE);
				}else if(textField_2.getText().isEmpty()){
					JOptionPane.showMessageDialog(null,"请输入任课教师!", "提示消息", JOptionPane.WARNING_MESSAGE);
				}else{
					MysqlConn.cno = textField.getText();
					MysqlConn.cname = textField_1.getText();
					MysqlConn.stucredit = textField_2.getText();
					
					MysqlConn.insertcou(MysqlConn.cno,MysqlConn.cname,MysqlConn.stucredit);
				}
			}
		});
		button.setBounds(146, 345, 78, 41);
		getContentPane().add(button);
		
		JButton button_1 = new JButton("重置");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				textField.setText("");
				textField_1.setText("");
				textField_2.setText("");
			}
		});
		button_1.setBounds(237, 344, 78, 41);
		getContentPane().add(button_1);
		
		JButton button_2 = new JButton("返回");
		button_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
				Cou co = new Cou();
			}
		});
		button_2.setBounds(330, 344, 78, 41);
		getContentPane().add(button_2);
		
		JButton button_3 = new JButton("退出");
		button_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		button_3.setBounds(423, 343, 78, 41);
		getContentPane().add(button_3);
		
		//给窗口设置标题
		this.setTitle("学生成绩管理系统-管理员-添加课程信息");
		//设置窗体大小
		this.setSize(650,520);
		//设置窗体初始位置
		this.setLocation(200, 150);
		//设置当关闭窗口时,保证JVM也退出
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//显示窗体
		this.setVisible(true);
		//窗体大小可变
		this.setResizable(true);
	}
}

③InsertStu.java

//插入学生的类
package gn;

import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.sql.Date;
import java.awt.event.ActionEvent;
import java.awt.FlowLayout;
import javax.swing.GroupLayout.Alignment;
import daoru.MysqlConn;
import SMIS.Stu;
import SMIS.Student;
import SMIS.Admin;
import SMIS.Cou;


public class InsertStu extends JFrame {
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	private JTextField textField_3;
	public InsertStu() {
		getContentPane().setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBounds(40, 12, 554, 397);
		getContentPane().add(panel);
		panel.setLayout(null);
		
		
		
		
		JComboBox comboBox_4 = new JComboBox();
		comboBox_4.setModel(new DefaultComboBoxModel(new String[] {"计算机科学与技术", "软件工程","测控技术与仪器","自动化","电子信息与工程"}));
		comboBox_4.setBounds(196, 220, 200, 24);
		panel.add(comboBox_4);
		
		
		
		
		
		JLabel label_4 = new JLabel("专业:");
		label_4.setBounds(137, 218, 54, 24);
		panel.add(label_4);
		label_4.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		
		JLabel label = new JLabel("学号:");
		label.setBounds(137, 61, 54, 24);
		panel.add(label);
		label.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		
		JComboBox comboBox_2 = new JComboBox();//年级对应的代码
		comboBox_2.setModel(new DefaultComboBoxModel(new String[] {"2020", "2019", "2018", "2017", "2016"}));
		comboBox_2.setBounds(196, 176, 70, 29);
		panel.add(comboBox_2);
		
	
		
		JLabel label_3 = new JLabel("年级:");
		label_3.setBounds(137, 176, 90, 24);//利用4个坐标进行控制代
		panel.add(label_3);
		label_3.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		
		JRadioButton radioButton_1 = new JRadioButton("女");
		radioButton_1.setBounds(270, 134, 47, 33);
		panel.add(radioButton_1);
		radioButton_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		
		JRadioButton radioButton = new JRadioButton("男");
		radioButton.setBounds(196, 134, 47, 33);
		panel.add(radioButton);
		radioButton.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));

		ButtonGroup bg = new ButtonGroup();
		bg.add(radioButton);
		bg.add(radioButton_1);
		
		JLabel label_2 = new JLabel("性别:");
		label_2.setBounds(137, 137, 54, 24);
		panel.add(label_2);
		label_2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		
		textField_1 = new JTextField();//第一个文本框
		textField_1.setBounds(196, 61, 121, 24);
		panel.add(textField_1);
		textField_1.setColumns(10);
		
		JLabel label_1 = new JLabel("姓名:");
		label_1.setBounds(137, 100, 54, 24);
		panel.add(label_1);
		label_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		
		textField = new JTextField();//第二个文本框
		textField.setBounds(196, 99, 121, 24);
		panel.add(textField);
		textField.setColumns(10);
		
		JLabel label_8 = new JLabel("请填写您要添加的学生信息:");
		label_8.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		label_8.setBounds(142, 18, 235, 30);
		panel.add(label_8);
		
		JPanel panel_1 = new JPanel();//
		panel_1.setBounds(109, 422, 416, 37);
		getContentPane().add(panel_1);
		
		JButton button = new JButton("确定");//确定按钮
		button.setBounds(51, 5, 63, 27);
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				MysqlConn.ConnectSQL();
				if(textField_1.getText().isEmpty()){
					JOptionPane.showMessageDialog(null,"请输入学号!","提示消息",JOptionPane.WARNING_MESSAGE);
				}else if(MysqlConn.querystu(textField_1.getText())){
					JOptionPane.showMessageDialog(null,"该学号已存在!\n请重新输入","提示消息",JOptionPane.WARNING_MESSAGE);
				}else if(!JudgeNum.judge(textField_1.getText(), textField_1.getText().length())){
					JOptionPane.showMessageDialog(null, "学号仅由数字组成,您输入的学号形式有误!\n请重新输入", "提示消息", JOptionPane.ERROR_MESSAGE);
				}else if(textField.getText().isEmpty()){
					JOptionPane.showMessageDialog(null,"请输入姓名!","提示消息",JOptionPane.WARNING_MESSAGE);
				}else if(!radioButton.isSelected() && !radioButton_1.isSelected()){
					JOptionPane.showMessageDialog(null,"请选择性别!","提示消息",JOptionPane.WARNING_MESSAGE);
				}else{//获取5个文本框与下拉框中的功能,且进行插入到内容中
					MysqlConn.stuid = textField_1.getText();//获取三个文本框的内容
					MysqlConn.stuname = textField.getText();
					if(radioButton.isSelected())
						MysqlConn.stusex = "男";
					else
						MysqlConn.stusex = "女";
					MysqlConn.stunj = (String) comboBox_2.getSelectedItem();
					MysqlConn.stuzy = (String) comboBox_4.getSelectedItem();
					
					//把学生信息插入到数据库中
					MysqlConn.insertstu();
				}
			}
		});
		panel_1.setLayout(null);
		panel_1.add(button);
		
		JButton button_1 = new JButton("返回");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
				Stu st = new Stu();
			}
		});
		button_1.setBounds(203, 5, 63, 27);
		panel_1.add(button_1);
		
		JButton button_2 = new JButton("退出");
		button_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		button_2.setBounds(280, 5, 63, 27);
		panel_1.add(button_2);
		
		JButton button_3 = new JButton("重置");
		button_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				textField.setText("");
				textField_1.setText("");
				textField_2.setText("");
				textField_3.setText("");
			}
		});
		button_3.setBounds(126, 5, 63, 27);
		panel_1.add(button_3);
		
		this.setTitle("学生成绩管理系统-管理员-添加学生信息");
		//设置窗体大小
		this.setSize(650,520);
		//设置窗体初始位置
		this.setLocation(200, 150);
		//设置当关闭窗口时,保证JVM也退出
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//显示窗体
		this.setVisible(true);
		//窗体大小可变
		this.setResizable(true);
	}
	

}

④JudgeNum.java

//判断是否是数字的类-->用于课程号处
package gn;

public class JudgeNum {
	
	public static boolean judge(String s,int len){
		for(int i = 0; i < len; i++){
			if(!Character.isDigit(s.charAt(i))){
				return false;
			}
		}
		return true;
	}
	
	public static boolean judge(String s){
		try{
			Float.valueOf(s);
			return true;
		}catch(Exception e){
			e.printStackTrace();
		}
		return false;
	}
	
	
}

⑤QueryCou.java

//查询课程的类
package gn;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import daoru.MysqlConn;
import SMIS.Stu;
import SMIS.Student;
import SMIS.Admin;
import SMIS.Cou;

public class QueryCou extends JFrame {
	private JTable table;
	public QueryCou() {
		getContentPane().setLayout(null);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(54, 148, 525, 180);
		getContentPane().add(scrollPane);
		
		table = new JTable();
		table.setRowHeight(30);
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
			},
			new String[] {
				"课程号", "课程名", "任课教师"
			}
		));
		table.getColumnModel().getColumn(0).setPreferredWidth(100);
		scrollPane.setViewportView(table);
		
		MysqlConn.ConnectSQL();
		MysqlConn.getdatacou();
		
		if(MysqlConn.counter == 0){
			JOptionPane.showMessageDialog(null, "课程还未导入!", "提示消息", JOptionPane.ERROR_MESSAGE);
		}
			
		for(int i = 0; i < MysqlConn.counter; i++){
			table.setValueAt(MysqlConn.c_no[i], i, 0);
			table.setValueAt(MysqlConn.c_name[i], i, 1);
			table.setValueAt(MysqlConn.c_rkjs[i], i, 2);
		}
		
		JLabel label = new JLabel("所有课程信息如下:");
		label.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		label.setBounds(235, 76, 164, 45);
		getContentPane().add(label);
		
		JButton button = new JButton("返回");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
				Cou co = new Cou();
			}
		});
		button.setBounds(199, 367, 89, 36);
		getContentPane().add(button);
		
		JButton button_1 = new JButton("退出");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		button_1.setBounds(362, 367, 89, 36);
		getContentPane().add(button_1);
		
		//给窗口设置标题
		this.setTitle("学生成绩管理系统-管理员-查询课程信息");
		//设置窗体大小
		this.setSize(650,520);
		//设置窗体初始位置
		this.setLocation(200, 150);
		//设置当关闭窗口时,保证JVM也退出
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//显示窗体
		this.setVisible(true);
		//窗体大小可变
		this.setResizable(true);
	}
}

⑥Query.java

//查询学生成绩与学生信息的类
package gn;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;

import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import daoru.MysqlConn;
import SMIS.Stu;
import SMIS.Student;
import SMIS.Admin;
import SMIS.Cou;


public class QueryStu extends JFrame{
	private JTable table;
	private JTable table_1;
	public QueryStu() {
		getContentPane().setLayout(null);
		
		JPanel panel_1 = new JPanel();
		panel_1.setBounds(0, 34, 882, 226);
		getContentPane().add(panel_1);
		panel_1.setLayout(null);
		
		JLabel label_1 = new JLabel("所有学生个人信息");
		label_1.setBounds(365, 15, 151, 24);
		panel_1.add(label_1);
		label_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(0, 52, 882, 152);
		panel_1.add(scrollPane);
		
		table = new JTable();
		table.setRowHeight(30);
		scrollPane.setViewportView(table);
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
			},
			new String[] {
				"学号", "姓名", "性别", "专业", "年级","","",""
			}
		));
		table.getColumnModel().getColumn(5).setPreferredWidth(100);
		
		JPanel panel_2 = new JPanel();
		panel_2.setBounds(156, 286, 642, 295);
		getContentPane().add(panel_2);
		panel_2.setLayout(null);
		
		JScrollPane scrollPane_1 = new JScrollPane();
		scrollPane_1.setBounds(0, 37, 642, 242);
		panel_2.add(scrollPane_1);
		
		table_1 = new JTable();
		table_1.setRowHeight(30);
		scrollPane_1.setViewportView(table_1);
		table_1.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
			},
			new String[] {
				"学号", "课程编号", "课程名称", "分数", "", ""
			}
		));
		
		MysqlConn.ConnectSQL();
		MysqlConn.getdatastu();//调用读取学生信息的函数
		if(MysqlConn.counter == 0){
			JOptionPane.showMessageDialog(null, "学生信息还未导入!", "提示消息", JOptionPane.ERROR_MESSAGE);
		}
		//返回学生信息的所有信息
		for(int i = 0; i < MysqlConn.counter; i++){
			table.setValueAt(MysqlConn.stu_sno[i], i, 0);
			table.setValueAt(MysqlConn.stu_name[i], i, 1);
			table.setValueAt(MysqlConn.stu_sex[i], i, 2);
			table.setValueAt(MysqlConn.stu_zy[i], i, 3);
			table.setValueAt(MysqlConn.stu_nj[i], i, 4);
		}
		
		MysqlConn.getdatagra();
		if(MysqlConn.counter == 0){
			JOptionPane.showMessageDialog(null, "学生成绩还未导入!", "提示消息", JOptionPane.ERROR_MESSAGE);
		}
		for(int i = 0; i < MysqlConn.counter; i++){
			table_1.setValueAt(MysqlConn.c_name[i], i, 0);
			table_1.setValueAt(MysqlConn.stu_kcbh[i], i, 1);
			table_1.setValueAt(MysqlConn.stu_kcmc[i], i, 2);
			table_1.setValueAt(MysqlConn.stu_point[i], i, 3);
		}
		
		JLabel label_2 = new JLabel("所有学生成绩信息");
		label_2.setBounds(201, 0, 167, 34);
		panel_2.add(label_2);
		label_2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
		
		JButton button = new JButton("返回");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
				Stu st = new Stu();
			}
		});
		button.setBounds(329, 603, 85, 37);
		getContentPane().add(button);
		
		JButton button_1 = new JButton("退出");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		button_1.setBounds(520, 603, 85, 37);
		getContentPane().add(button_1);
		
		this.setTitle("学生成绩管理系统-管理员-查询学生信息");
		//设置窗体大小
		this.setSize(900,700);
		//设置窗体初始位置
		this.setLocation(200, 150);
		//设置当关闭窗口时,保证JVM也退出
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//显示窗体
		this.setVisible(true);
		//窗体大小可变
		this.setResizable(true);
	}
}

最终界面类

①登录界面

gui数据库编程 java 数据库课设java_数据库



gui数据库编程 java 数据库课设java_数据库_02


gui数据库编程 java 数据库课设java_gui数据库编程 java_03

其余类就不完全演示了