java+swing+mysql学生成绩管理系统

学生成绩管理系统

  • java+swing+mysql
  • windowbuilder
  • 先上主界面图片
  • 代码
  • 最后
  • 使用该程序或者是想要学习更简单的课设

java+swing+mysql

这是大二的java课设,主要是用了 Eclipse,windowbuilder插件和mysql完成,介于csdn上大多数界面做的很复古,让人以为swing做的界面很丑,所以我发布这个博客反驳一下,swing照样可以做的很好看(可能我做的还不是很好看)。

windowbuilder

windowbuider是个挺好的插件,但是有人说他并不好,其一 容易崩溃,其二 写的代码太乱。我通过摸索得到了更多的windowbuilder正确使用的方法,但是windowbuilder的使用教程并不在本博客内。

先上主界面图片

这是今年做的管理系统主界面qu图片: java+swing+mysql学生成绩管理系统_第1张图片
插入和查询等功能都实现了 查询功能还实现了不同科目的排名
java+swing+mysql学生成绩管理系统_第2张图片
右边的滚动条还是有点丑,实在不会操作了,不过比原版的JTable好看多了
java+swing+mysql学生成绩管理系统_第3张图片

fng一下去年做的被老师吐槽的界面:java+swing+mysql学生成绩管理系统_第4张图片
是不是差距瞬间就有了,看了今年的这个界面,去年的简直不忍直视

#层次结构
java+swing+mysql学生成绩管理系统_第5张图片

当然我现在其实还是初学者- -结构还是很乱的

代码

//student
public class student {
	private String name;
	private double java;
	private double math;
	private double datastruct;
	private double english;
	private double total;
	private double Average;
	private int paiming;
	public int getPaiming() {
		return paiming;
	}
	public void setPaiming(int paiming) {
		this.paiming = paiming;
	}
	public student(String name, double java, double math, double datastruct, double english, double total,
			double average) {
		super();
		this.name = name;
		this.java = java;
		this.math = math;
		this.datastruct = datastruct;
		this.english = english;
		this.total = total;
		Average = average;
	}
	@Override
	public String toString() {
		return "student [name=" + name + ", java=" + java + ", math=" + math + ", datastruct=" + datastruct
				+ ", english=" + english + ", total=" + total + ", Average=" + Average + "]";
	}
	public student() {
		// TODO Auto-generated constructor stub
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public double getJava() {
		return java;
	}
	public void setJava(double java) {
		this.java = java;
	}
	public double getMath() {
		return math;
	}
	public void setMath(double math) {
		this.math = math;
	}
	public double getDatastruct() {
		return datastruct;
	}
	public void setDatastruct(double datastruct) {
		this.datastruct = datastruct;
	}
	public double getEnglish() {
		return english;
	}
	public void setEnglish(double english) {
		this.english = english;
	}
	public double getTotal() {
		return total;
	}
	public void setTotal(double total) {
		this.total = total;
	}
	public double getAverage() {
		return Average;
	}
	public void setAverage(double average) {
		Average = average;
	}
	
}
//dao
import java.sql.SQLException;
import java.util.List;

import beans.student;

public interface dao {
    public abstract int add(String name,double java,double math,double datastruct,double english);
    //添加
    public abstract int remove(String name) throws SQLException, ClassNotFoundException;
    //删除通过姓名
    public abstract int removexuehao(int xuhao) throws SQLException, ClassNotFoundException;
    //删除通过序号

    //修改
    public abstract student selectName(String name);
    //根据姓名查询

    public abstract List<student> sortjava() throws SQLException;
    //排序
    public abstract  List<student> sortmath() throws SQLException;
    public abstract  List<student> sortdatastruct() throws SQLException;
    public abstract  List<student> sortenglish() throws SQLException;
    public abstract  List<student> sortzongfen() throws SQLException;
    public abstract  List<student> sortpingjunfen() throws SQLException;

    public abstract List<student> show();
}
    //显示所有联系人


//daoimp
public class daoimp implements dao {

    private Connection conn;
    private PreparedStatement pst;
    private ResultSet res;
    public int add(String name,double java,double math,double datastruct,double english) {
    	int a = 0;
    	double total =java+math+datastruct+english;
    	double average = (java+math+datastruct+english)/4;
    	System.out.println(average);
        try {
            conn = (Connection) dbutils.getConn();
            String sql = "insert into student(name,java,math,datastruct,english,zongfen,pingjunfen) values (?,?,?,?,?,?,?)";
            pst=conn.prepareStatement(sql); // 预编译sql语句
            //repareStatement这个方法会将SQL语句加载到驱动程序conn集成程序中
            //但是并不直接执行,而是当它调用execute()方法的时候才真正执行
           
            pst.setString(1,name); //给第1个占位符赋值
			pst.setDouble(2,java);
            pst.setDouble(3,math);
            pst.setDouble(4,datastruct);
            pst.setDouble(5,english);
            pst.setDouble(6,total);
            pst.setDouble(7,average);
           a=pst.executeUpdate(); // 执行SQL语句
           System.out.println("hasjaj");
        } catch (SQLException e) {
        } catch (ClassNotFoundException e) {
        }finally {
        	dbutils.close(pst,conn,res);
           
        }
		return a;
    }
   
   

    @Override
    public int remove(String name)  {
    	int a = 0;
        try {
            conn = (Connection) dbutils.getConn();
            String sql = "delete from student where name=?";
            pst=conn.prepareStatement(sql);// 预编译sql语句
            pst.setString(1,name);
            a = pst.executeUpdate();// 执行SQL语句
        } catch (SQLException e) {
        } catch (ClassNotFoundException e) {
        }finally {
        	dbutils.close(pst,conn,res);
        }
        return a;
    }

    @Override
    
    public student selectName(String name)  {
    	student person = null;
       try{
           conn = (Connection) dbutils.getConn();
           String sql = "select * from student where name = ?";
           pst=conn.prepareStatement(sql);// 预编译sql语句
           pst.setString(1,name);
           res = pst.executeQuery();// 执行SQL语句
           if(res.next()) {
               person = new student();
               person.setName(res.getString("name"));
               person.setJava(res.getDouble("java"));
               person.setMath(res.getDouble("math"));
               person.setDatastruct(res.getDouble("datastruct"));
               person.setEnglish(res.getDouble("english"));
               person.setTotal(res.getDouble("zongfen"));
               person.setAverage(res.getDouble("pingjunfen"));

           }
       }catch (SQLException e){
           e.printStackTrace();
       } catch (ClassNotFoundException e) {
           e.printStackTrace();
       } catch (Throwable e) {
           e.printStackTrace();

       }finally {
    	   dbutils.close(pst,conn,res);
            return person;

        }
    }

    /*   @Override
   public student selectNum(String num) {
    	student person = null;
        try{
            conn = (Connection) dbutils.getConn();
            String sql = "select * from tongxunlu where num = ?";
            pst=conn.prepareStatement(sql);// 预编译sql语句
            pst.setString(1,num);
            res = pst.executeQuery();// 执行SQL语句
            if(res.next()) {
                person = new student();
                person.setName(res.getString("name"));
                person.setJava(res.getDouble("ss"));
                person.setMath(res.getDouble("num"));
                person.setDatastruct(res.getDouble("school"));
                person.setTotal(res.getDouble("e_mail"));
                person.setAverage(res.getDouble("guanxi"));
            }
        }catch (SQLException e){
        } catch (ClassNotFoundException e) {
        }finally {
        	dbutils.close(pst,conn,res);
            return person;
        }
    }
    */
    @Override
    public  List<student> sortjava() {
        List<student> list = new ArrayList<>();
        try {
            conn = (Connection) dbutils.getConn();
            String sql = "select * From student ORDER BY java desc";
            pst = conn.prepareStatement(sql);
            res = pst.executeQuery();
            while(res.next()){
            	student person = new student();
            	person.setPaiming(res.getInt("paiming"));
            	person.setName(res.getString("name"));
                person.setJava(res.getDouble("java"));
                person.setMath(res.getDouble("math"));
                person.setDatastruct(res.getDouble("datastruct"));
                person.setEnglish(res.getDouble("english"));
                person.setTotal(res.getDouble("zongfen"));
                person.setAverage(res.getDouble("pingjunfen"));
                list.add(person);
            }
            for(student c:list){
                System.out.println(c.toString());
            }
        } catch (SQLException e) {
        } catch (ClassNotFoundException e) {
        }finally {
        	dbutils.close(pst,conn,res);
        }
    	return list;

    }

    @SuppressWarnings("finally")
	@Override
    public List<student> show() {
        List<student> list = new ArrayList<>();
        try {
            conn = (Connection) dbutils.getConn();
            String sql = "select * from student ORDER  BY zongfen desc";
            pst=conn.prepareStatement(sql);
            res = pst.executeQuery();
            while(res.next()){
            	student person = new student();
            	person.setName(res.getString("name"));
                person.setJava(res.getDouble("java"));
                person.setMath(res.getDouble("math"));
                person.setDatastruct(res.getDouble("datastruct"));
                person.setDatastruct(res.getDouble("english"));
                person.setTotal(res.getDouble("zongfen"));
                person.setAverage(res.getDouble("pingjunfen"));
                list.add(person);
            }
            for(student c:list){
                System.out.println(c.toString());
            }
        } catch (SQLException e) {
        } catch (ClassNotFoundException e) {
        }finally {
        	dbutils.close(pst,conn,res);
            return list;
        }
    }
    public int removeall()  {
    	int a = 0;
        try {
            conn = (Connection) dbutils.getConn();
            String sql = "truncate table student";
            pst=conn.prepareStatement(sql);// 预编译sql语句
            a = pst.executeUpdate();// 执行SQL语句
        } catch (SQLException e) {
        } catch (ClassNotFoundException e) {
        }finally {
        	dbutils.close(pst,conn,res);
        }
        return a;
    }
    public void chongxinbaocun(List<student> l) {
        int a = 0;
        for(student c:l){
        	  try {
				conn = (Connection) dbutils.getConn();
				conn = (Connection) dbutils.getConn();
	            String sql = "insert into student(name,java,math,datastruct,english,zongfen,pingjunfen) values (?,?,?,?,?,?,?)";
	            pst=conn.prepareStatement(sql); // 预编译sql语句
	            //repareStatement这个方法会将SQL语句加载到驱动程序conn集成程序中
	            //但是并不直接执行,而是当它调用execute()方法的时候才真正执行
	           
	            pst.setString(1,c.getName()); //给第1个占位符赋值
				pst.setDouble(2,c.getJava());
	            pst.setDouble(3,c.getMath());
	            pst.setDouble(4,c.getDatastruct());
	            pst.setDouble(5,c.getEnglish());
	            pst.setDouble(6,c.getTotal());
	            pst.setDouble(7,c.getAverage());
	           a=pst.executeUpdate(); // 执行SQL语句       }
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
              finally {
            	  dbutils.close(pst,conn,res);
			}
          	
        }
    }

    public static void main(String[] args) {
		
    	daoimp a = new daoimp();
    	List<student> b = a.show();
    	a.removeall();
    	a.chongxinbaocun(b);
	}

	@Override
	public int removexuehao(int xuhao) throws SQLException, ClassNotFoundException {
		int a = 0;
        try {
            conn = (Connection) dbutils.getConn();
            String sql = "delete from student where xuehao=?";
            pst=conn.prepareStatement(sql);// 预编译sql语句
            pst.setInt(1,xuhao);
            a = pst.executeUpdate();// 执行SQL语句
        } catch (SQLException e) {
        } catch (ClassNotFoundException e) {
        }finally {
        	dbutils.close(pst,conn,res);
        }
        return a;		
	}


	@Override
	public  List<student> sortmath() throws SQLException {
		List<student> list = new ArrayList<>();
        try {
            conn = (Connection) dbutils.getConn();
            String sql = "select * From student ORDER BY math desc";
            pst = conn.prepareStatement(sql);
            res = pst.executeQuery();
            while(res.next()){
            	student person = new student();
                person.setPaiming(res.getInt("paiming"));

            	person.setName(res.getString("name"));
                person.setJava(res.getDouble("java"));
                person.setMath(res.getDouble("math"));
                person.setDatastruct(res.getDouble("datastruct"));
                person.setEnglish(res.getDouble("english"));
                person.setTotal(res.getDouble("zongfen"));
                person.setAverage(res.getDouble("pingjunfen"));
                list.add(person);
            }
            for(student c:list){
                System.out.println(c.toString());
            }
        } catch (SQLException e) {
        } catch (ClassNotFoundException e) {
        }finally {
        	dbutils.close(pst,conn,res);
        }
    	return list;		
	}


	@Override
	public  List<student> sortdatastruct() throws SQLException {
		List<student> list = new ArrayList<>();
        try {
            conn = (Connection) dbutils.getConn();
            String sql = "select * From student ORDER BY datastruct desc";
            pst = conn.prepareStatement(sql);
            res = pst.executeQuery();
            while(res.next()){
            	student person = new student();
                person.setPaiming(res.getInt("paiming"));

            	person.setName(res.getString("name"));
                person.setJava(res.getDouble("java"));
                person.setMath(res.getDouble("math"));
                person.setDatastruct(res.getDouble("datastruct"));
                person.setEnglish(res.getDouble("english"));
                person.setTotal(res.getDouble("zongfen"));
                person.setAverage(res.getDouble("pingjunfen"));
                list.add(person);
            }
            for(student c:list){
                System.out.println(c.toString());
            }
        } catch (SQLException e) {
        } catch (ClassNotFoundException e) {
        }finally {
        	dbutils.close(pst,conn,res);
        }
    	return list;		
	}


	@Override
	public  List<student> sortenglish() throws SQLException {
		List<student> list = new ArrayList<>();
        try {
            conn = (Connection) dbutils.getConn();
            String sql = "select * From student ORDER BY english desc";
            pst = conn.prepareStatement(sql);
            res = pst.executeQuery();
            while(res.next()){
            	student person = new student();
                person.setPaiming(res.getInt("paiming"));

            	person.setName(res.getString("name"));
                person.setJava(res.getDouble("java"));
                person.setMath(res.getDouble("math"));
                person.setDatastruct(res.getDouble("datastruct"));
                person.setEnglish(res.getDouble("english"));
                person.setTotal(res.getDouble("zongfen"));
                person.setAverage(res.getDouble("pingjunfen"));
                list.add(person);
            }
            for(student c:list){
                System.out.println(c.toString());
            }
        } catch (SQLException e) {
        } catch (ClassNotFoundException e) {
        }finally {
        	dbutils.close(pst,conn,res);
        }
    	return list;		
	}


	@Override
	public  List<student> sortzongfen() throws SQLException {
		List<student> list = new ArrayList<>();
        try {
            conn = (Connection) dbutils.getConn();
            String sql = "select * From student ORDER BY zongfen desc";
            pst = conn.prepareStatement(sql);
            res = pst.executeQuery();
            while(res.next()){
            	student person = new student();
                person.setPaiming(res.getInt("paiming"));
            	person.setName(res.getString("name"));
                person.setJava(res.getDouble("java"));
                person.setMath(res.getDouble("math"));
                person.setDatastruct(res.getDouble("datastruct"));
                person.setEnglish(res.getDouble("english"));
                person.setTotal(res.getDouble("zongfen"));
                person.setAverage(res.getDouble("pingjunfen"));
                list.add(person);
            }
            for(student c:list){
                System.out.println(c.toString());
            }
        } catch (SQLException e) {
        } catch (ClassNotFoundException e) {
        }finally {
        	dbutils.close(pst,conn,res);
        }
    	return list;		 
	}


	@Override
	public  List<student> sortpingjunfen() throws SQLException {
		List<student> list = new ArrayList<>();
        try {
            conn = (Connection) dbutils.getConn();
            String sql = "select * From student ORDER BY pingjunfen desc";
            pst = conn.prepareStatement(sql);
            res = pst.executeQuery();
            while(res.next()){
            	student person = new student();
                person.setPaiming(res.getInt("paiming"));

            	person.setName(res.getString("name"));
                person.setJava(res.getDouble("java"));
                person.setMath(res.getDouble("math"));
                person.setDatastruct(res.getDouble("datastruct"));
                person.setEnglish(res.getDouble("english"));
                person.setTotal(res.getDouble("zongfen"));
                person.setAverage(res.getDouble("pingjunfen"));
                list.add(person);
            }
            for(student c:list){
                System.out.println(c.toString());
            }
        } catch (SQLException e) {
        } catch (ClassNotFoundException e) {
        }finally {
        	dbutils.close(pst,conn,res);
        }
    	return list;		
	}







}
//其实这里写的太过于冗杂,只是为了方便对各项成绩进行排名,大家写的时候应该会有更好的方法


//dbutils
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class dbutils {
    private static String url = "jdbc:mysql://127.0.0.1:3306/text?useSSL=false&useUnicode=yes&characterEncoding=UTF-8";
    private static String user = "root"; //数据库用户名
    private static String password = "1234"; //数据库密码

    public static Connection getConn() throws SQLException, ClassNotFoundException {
        //1.加载驱动程序
        Class.forName("com.mysql.jdbc.Driver");
        //2.获得数据库的连接
        return DriverManager.getConnection(url, user, password);
    }

    public static void close(Statement stat, Connection conn, ResultSet res) {
        //关闭结果集
        if( stat != null){
            try {
                stat.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        //关闭命令
        if( conn != null){
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        //关闭连接
        if( res != null){
            try {
                res.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}
//连接数据库的工具类
//view.start开始界面

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.event.AncestorListener;
import javax.swing.event.AncestorEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JRadioButton;
import java.awt.Font;
import javax.swing.JMenuItem;
import javax.swing.JMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JPopupMenu;
import java.awt.Component;
import javax.swing.JTextArea;
import javax.swing.UIManager;

import java.awt.Button;
import java.awt.Color;
import java.awt.Panel;
import javax.swing.JScrollBar;
import java.awt.Toolkit;
import javax.swing.JTabbedPane;
import java.awt.ScrollPane;
import java.awt.FlowLayout;
import java.awt.Dimension;

public class start extends JFrame {

	private JPanel contentPane;
	private final JPanel panel = new JPanel();

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					start frame = new start();
					frame.setLocation(505,200);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public start() {
		setTitle("\u5B66\u751F\u6210\u7EE9\u7BA1\u7406\u7CFB\u7EDF");
		setIconImage(Toolkit.getDefaultToolkit().getImage(start.class.getResource("/\u84DD\u8272/\u5B66\u751F (1).png")));
		setBackground(Color.LIGHT_GRAY);
		//setUndecorated(true);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 904, 570);
		contentPane = new JPanel();
		contentPane.setBackground(Color.WHITE);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		panel.setBackground(new Color(30, 144, 255));
		panel.setBounds(0, 0, 86, 523);
		contentPane.add(panel);
		panel.setLayout(null);
		
		JButton btnNewButton = new JButton("");
		btnNewButton.setIcon(new ImageIcon(start.class.getResource("/\u767D\u8272/add (2).png")));
		btnNewButton.setContentAreaFilled(false);
		btnNewButton.setFocusPainted(false);
		btnNewButton.setBorder(null);
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				zengjia();
			}
		});
		btnNewButton.setBounds(0, 0, 77, 91);
		panel.add(btnNewButton);
		
		JButton btnNewButton_1 = new JButton("");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					shanchu();
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		btnNewButton_1.setIcon(new ImageIcon(start.class.getResource("/\u767D\u8272/del (2).png")));
		btnNewButton_1.setFocusPainted(false);
		btnNewButton_1.setContentAreaFilled(false);
		btnNewButton_1.setBorder(null);
		btnNewButton_1.setBounds(0, 78, 77, 77);
		panel.add(btnNewButton_1);
		
		JButton btnNewButton_2 = new JButton("");
		btnNewButton_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				xiugai();
			}
		});
		btnNewButton_2.setIcon(new ImageIcon(start.class.getResource("/\u767D\u8272/reset (2).png")));
		btnNewButton_2.setFocusPainted(false);
		btnNewButton_2.setContentAreaFilled(false);
		btnNewButton_2.setBorder(null);
		btnNewButton_2.setBounds(0, 156, 77, 77);
		panel.add(btnNewButton_2);
		
		JButton btnNewButton_3 = new JButton("");
		btnNewButton_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				chaozhao();
			}
		});
		btnNewButton_3.setIcon(new ImageIcon(start.class.getResource("/\u767D\u8272/search (2).png")));
		btnNewButton_3.setFocusPainted(false);
		btnNewButton_3.setContentAreaFilled(false);
		btnNewButton_3.setBorder(null);
		btnNewButton_3.setBounds(0, 235, 77, 77);
		panel.add(btnNewButton_3);
		
		JButton btnNewButton_3_1 = new JButton("");
		btnNewButton_3_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				shezhi();
			}
		});
		btnNewButton_3_1.setIcon(new ImageIcon(start.class.getResource("/\u767D\u8272/\u8BBE \u7F6E (1).png")));
		btnNewButton_3_1.setFocusPainted(false);
		btnNewButton_3_1.setContentAreaFilled(false);
		btnNewButton_3_1.setBorder(null);
		btnNewButton_3_1.setBounds(0, 446, 77, 77);
		panel.add(btnNewButton_3_1);
		
		JPanel panel_1 = new JPanel();
		panel_1.setBackground(new Color(30, 144, 255));
		panel_1.setBounds(85, 0, 801, 60);
		contentPane.add(panel_1);
		
		JLabel lblNewLabel = new JLabel("");
		lblNewLabel.setIcon(new ImageIcon(start.class.getResource("/zhujiemian/\u7EC4\u7EC7\u67B6\u67842.5D.png")));
		lblNewLabel.setBounds(-198, 29, 907, 599);
		contentPane.add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("");
		lblNewLabel_1.setIcon(new ImageIcon(start.class.getResource("/zhujiemian/\u8282\u70B9\u7BA1\u74062.5D.png")));
		lblNewLabel_1.setBounds(202, -18, 684, 646);
		contentPane.add(lblNewLabel_1);
	}
	protected void shezhi() {
		shezhi sh = new shezhi();
	}

	protected void chaozhao() {
		select	s = new select();	
	}

	protected void xiugai() {
		reright r =new reright();
	}

	protected void shanchu() throws Exception {
		delete d =new delete();
	}

	protected void zengjia() {

		add a = new add();
		
	}

	private static void addPopup(Component component, final JPopupMenu popup) {
		component.addMouseListener(new MouseAdapter() {
			public void mousePressed(MouseEvent e) {
				if (e.isPopupTrigger()) {
					showMenu(e);
				}
			}
			public void mouseReleased(MouseEvent e) {
				if (e.isPopupTrigger()) {
					showMenu(e);
				}
			}
			private void showMenu(MouseEvent e) {
				popup.show(e.getComponent(), e.getX(), e.getY());
			}
		});
	}
}

//view.add界面

public class add extends JFrame {
	tianjiachenggong t = new tianjiachenggong();
	bunengweikong b = new bunengweikong();
	daoimp d = new daoimp();
	private JPanel contentPane;
	private JTextField xueshengtextField;
	private JTextField javatextField_1;
	private JTextField shuxuetextField_2;
	private JTextField shujujiegoutextField_3;
	private JTextField yingyutextField_4;

public static void main(String[] args) {
	add a = new add();
	
}

	/**
	 * Create the frame.
	 */
	public add() {
		setUndecorated(true);
		setBackground(Color.WHITE);


		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 800, 525);
		setLocation(600,238);
		setVisible(true);
		contentPane = new JPanel();
		contentPane.setBackground(Color.WHITE);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		contentPane.setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBackground(new Color(30, 144, 255));
		panel.setBounds(0, 0, 800, 60);
		contentPane.add(panel);
		panel.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("\u6DFB\u52A0");
		lblNewLabel.setFont(new Font("宋体", Font.PLAIN, 30));
		lblNewLabel.setForeground(new Color(255, 255, 255));
		lblNewLabel.setBounds(0, 0, 112, 53);
		panel.add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("\u5B66\u751F\u59D3\u540D");
		lblNewLabel_1.setFont(new Font("宋体", Font.PLAIN, 20));
		lblNewLabel_1.setBounds(31, 111, 117, 38);
		contentPane.add(lblNewLabel_1);
		
		JLabel lblNewLabel_1_1 = new JLabel("java\u6210\u7EE9");
		lblNewLabel_1_1.setFont(new Font("宋体", Font.PLAIN, 20));
		lblNewLabel_1_1.setBounds(31, 162, 117, 38);
		contentPane.add(lblNewLabel_1_1);
		
		JLabel lblNewLabel_1_2 = new JLabel("\u6570\u5B66\u6210\u7EE9");
		lblNewLabel_1_2.setFont(new Font("宋体", Font.PLAIN, 20));
		lblNewLabel_1_2.setBounds(31, 213, 117, 38);
		contentPane.add(lblNewLabel_1_2);
		
		JLabel lblNewLabel_1_3 = new JLabel("\u6570\u636E\u7ED3\u6784");
		lblNewLabel_1_3.setFont(new Font("宋体", Font.PLAIN, 20));
		lblNewLabel_1_3.setBounds(31, 264, 117, 38);
		contentPane.add(lblNewLabel_1_3);
		
		JLabel lblNewLabel_1_4 = new JLabel("\u82F1\u8BED\u6210\u7EE9");
		lblNewLabel_1_4.setFont(new Font("新宋体", Font.PLAIN, 20));
		lblNewLabel_1_4.setBounds(31, 315, 117, 38);
		contentPane.add(lblNewLabel_1_4);
		
		xueshengtextField = new JTextField();
		xueshengtextField.setBounds(170, 118, 373, 24);
		contentPane.add(xueshengtextField);
		xueshengtextField.setColumns(10);
		
		javatextField_1 = new JTextField();
		javatextField_1.setColumns(10);
		javatextField_1.setBounds(170, 169, 373, 24);
		contentPane.add(javatextField_1);
		
		shuxuetextField_2 = new JTextField();
		shuxuetextField_2.setColumns(10);
		shuxuetextField_2.setBounds(170, 220, 373, 24);
		contentPane.add(shuxuetextField_2);
		
		shujujiegoutextField_3 = new JTextField();
		shujujiegoutextField_3.setColumns(10);
		shujujiegoutextField_3.setBounds(170, 271, 373, 24);
		contentPane.add(shujujiegoutextField_3);
		
		yingyutextField_4 = new JTextField();
		yingyutextField_4.setColumns(10);
		yingyutextField_4.setBounds(170, 322, 373, 24);
		contentPane.add(yingyutextField_4);
		
		JButton btnNewButton = new JButton("\u786E\u8BA4\u63D0\u4EA4");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					tijiao(e);
				} catch (InterruptedException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});

		Border bored = BorderFactory.createLineBorder(new Color(30, 144, 255));
		btnNewButton.setBorder(bored);

		btnNewButton.setFont(new Font("宋体", Font.PLAIN, 20));
		btnNewButton.setFocusPainted(false);
		btnNewButton.setForeground(new Color(30, 144, 255));
		btnNewButton.setBackground(new Color(255, 255, 255));
		btnNewButton.setBounds(196, 427, 127, 38);
		contentPane.add(btnNewButton);
		
		JButton btnNewButton_1 = new JButton("\u91CD\u65B0\u8F93\u5165");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				qingkong(e);
			}
		});
		btnNewButton_1.setBorder(bored);
		btnNewButton_1.setForeground(new Color(30, 144, 255));
		btnNewButton_1.setFont(new Font("宋体", Font.PLAIN, 20));
		btnNewButton_1.setFocusPainted(false);
		btnNewButton_1.setBackground(Color.WHITE);
		btnNewButton_1.setBounds(519, 427, 127, 38);
		contentPane.add(btnNewButton_1);
	}

	protected void qingkong(ActionEvent e) {
		xueshengtextField.setText("");
		javatextField_1.setText("");
		shuxuetextField_2.setText("");;
		shujujiegoutextField_3.setText("");;
		yingyutextField_4.setText("");;
		
	}

	protected void tijiao(ActionEvent e) throws InterruptedException {
		
		

		int o =0;
		String name = null;
		if(StringUtils.isNullOrEmpty(xueshengtextField.getText())||StringUtils.isNullOrEmpty(javatextField_1.getText())||StringUtils.isNullOrEmpty(shuxuetextField_2.getText())||StringUtils.isNullOrEmpty(shujujiegoutextField_3.getText())||StringUtils.isNullOrEmpty(yingyutextField_4.getText()))
			b.setVisible(true);
		else
			
		 name = xueshengtextField.getText();
		double javas=Double.parseDouble(javatextField_1.getText());
		double shuxues =Double.parseDouble(shuxuetextField_2.getText());
		double shujujiegous = Double.parseDouble(shujujiegoutextField_3.getText());
		double yingyus  =Double.parseDouble (yingyutextField_4.getText());
		/*		if(StringUtils.isNullOrEmpty(name)||StringUtils.isNullOrEmpty(javas)||StringUtils.isNullOrEmpty(shuxues)||StringUtils.isNullOrEmpty(shujujiegous)||StringUtils.isNullOrEmpty(yingyus))
		//	JOptionPane.showMessageDialog(this, "不能输入为空!");
		  */
			//t.setVisible(true);
			
	   o= d.add(name, javas, shuxues, shujujiegous, yingyus);
		if(o!=0) {
			t.setVisible(true);
		dispose();
		}
		qingkong(e);

	
}
}

//view.delete 删除界面
public class delete extends JFrame {

	tianjiachenggong t = new tianjiachenggong();
	bunengweikong b = new bunengweikong();
	meiyoushuju m = new meiyoushuju();
	private JPanel contentPane;
	private JTextField textField;
	private JTable table;
	private JScrollPane scrollPane;
	private JLabel lblNewLabel_1;

	shanchshibai s = new shanchshibai();
public static void main(String[] args) throws Exception {
	delete a = new delete();
	
}

	/**

	
	 */
	public delete() {		
		
		setUndecorated(true);
		setBackground(Color.WHITE);


		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 800, 525);
		setLocation(600,238);
		setVisible(true);
		contentPane = new JPanel();
		contentPane.setBackground(Color.WHITE);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		contentPane.setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBackground(new Color(30, 144, 255));
		panel.setBounds(0, 0, 800, 60);
		contentPane.add(panel);
		panel.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("\u5220\u9664");
		lblNewLabel.setForeground(Color.WHITE);
		lblNewLabel.setFont(new Font("宋体", Font.PLAIN, 30));
		lblNewLabel.setBounds(0, 0, 112, 53);
		panel.add(lblNewLabel);
		
		textField = new JTextField();
		textField.setBounds(666, 144, 120, 38);
		Border boredetextField = BorderFactory.createLineBorder(new Color(30, 144, 255));
		textField.setBorder(boredetextField);

		contentPane.add(textField);
		textField.setColumns(10);
		
		JButton btnNewButton = new JButton("\u786E\u8BA4\u5220\u9664");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					shanchu(e);
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		btnNewButton.setForeground(new Color(30, 144, 255));
		btnNewButton.setFont(new Font("宋体", Font.PLAIN, 20));
		btnNewButton.setFocusPainted(false);

		Border bored = BorderFactory.createLineBorder(new Color(30, 144, 255));
		btnNewButton.setBorder(bored);

		btnNewButton.setBackground(Color.WHITE);
		btnNewButton.setBounds(666, 348, 120, 38);
		contentPane.add(btnNewButton);
		
		scrollPane = new JScrollPane();

		 scrollPane.getVerticalScrollBar().setBackground((new Color(30, 144, 255)));

		scrollPane.setBorder(null);
		scrollPane.setBounds(0, 55, 637, 470);
		scrollPane.setOpaque(false);
		scrollPane.getViewport().setOpaque(false);
		contentPane.add(scrollPane);
		
		table = new JTable();
		table.setCellSelectionEnabled(true);
		table.setOpaque(false);
		table.getTableHeader().setBackground(Color.WHITE);


		table.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"\u6392\u540D", "\u59D3\u540D", "java", "\u6570\u5B66", "\u6570\u636E\u7ED3\u6784", "\u82F1\u8BED", "\u5E73\u5747\u5206", "\u603B\u5206"
			}
		));
		scrollPane.setViewportView(table);
		table.setBackground(Color.WHITE);
		
		lblNewLabel_1 = new JLabel("\u8F93\u5165\u8981\u5220\u9664\u7684\u59D3\u540D\uFF1A");
		lblNewLabel_1.setForeground(new Color(0, 0, 0));
		lblNewLabel_1.setFont(new Font("微软雅黑", Font.PLAIN, 15));
		lblNewLabel_1.setBounds(663, 89, 148, 53);
		contentPane.add(lblNewLabel_1);
		
		JButton btnNewButton_1 = new JButton("\u67E5\u770B\u6240\u6709");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					chakansuoyou(e);
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		btnNewButton_1.setBorder(bored);

		btnNewButton_1.setForeground(new Color(30, 144, 255));
		btnNewButton_1.setFont(new Font("宋体", Font.PLAIN, 20));
		btnNewButton_1.setFocusPainted(false);
		btnNewButton_1.setBackground(Color.WHITE);
		btnNewButton_1.setBounds(666, 278, 120, 38);
		contentPane.add(btnNewButton_1);
		
		JButton btnNewButton_2 = new JButton("\u5173\u95ED\u7A97\u53E3");
		btnNewButton_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});
		btnNewButton_2.setForeground(new Color(30, 144, 255));
		btnNewButton_2.setFont(new Font("宋体", Font.PLAIN, 20));
		btnNewButton_2.setFocusPainted(false);
		btnNewButton_2.setBorder(bored);

		btnNewButton_2.setBackground(Color.WHITE);
		btnNewButton_2.setBounds(666, 419, 120, 38);
		contentPane.add(btnNewButton_2);
	}

	protected void shanchu(ActionEvent e) throws SQLException {
		int ab = 0;
		daoimp c = new daoimp();
		if(StringUtils.isNullOrEmpty(textField.getText()))
			b.setVisible(true);
			else {

		ab = c.remove(textField.getText());
		if(ab!=0) {
		t.setVisible(true);
		dispose();}

		else {
        m.setVisible(true);
		}
			}

		chakansuoyou(e);
		
	}


	protected void chakansuoyou(ActionEvent e) throws SQLException {
		daoimp da = new daoimp();
		DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
		tableModel.setRowCount(0);
		List<student> a = da.sortzongfen();
		da.removeall();
		da.chongxinbaocun(a);
		List<student> c = da.sortzongfen();

	     for(student vector :c ){
             String[] t = {String.valueOf(vector.getPaiming()),vector.getName(),String.valueOf(vector.getJava()),String.valueOf(vector.getMath()),String.valueOf(vector.getDatastruct()),String.valueOf(vector.getEnglish()),String.valueOf(vector.getAverage()),String.valueOf(vector.getTotal())};
          tableModel.addRow(t);
      }				
	}
}

view.reright 修改界面
public class reright extends JFrame {
	meiyoushuju m = new meiyoushuju();
	tianjiachenggong t = new tianjiachenggong();
	bunengweikong b = new bunengweikong();
	daoimp d = new daoimp();
	private JPanel contentPane;
	private JTextField xueshengtextField;
	private JTextField javatextField_1;
	private JTextField shuxuetextField_2;
	private JTextField shujujiegoutextField_3;
	private JTextField yingyutextField_4;
	private JTextField jiutextField;

public static void main(String[] args) {
	reright a = new reright();
	
}

	/**
	 * Create the frame.
	 */
	public reright() {
		setUndecorated(true);
		setBackground(Color.WHITE);


		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 800, 525);
		setLocation(600,238);
		setVisible(true);
		contentPane = new JPanel();
		contentPane.setBackground(Color.WHITE);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		contentPane.setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBackground(new Color(30, 144, 255));
		panel.setBounds(0, 0, 800, 60);
		contentPane.add(panel);
		panel.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("\u6DFB\u52A0");
		lblNewLabel.setFont(new Font("宋体", Font.PLAIN, 30));
		lblNewLabel.setForeground(new Color(255, 255, 255));
		lblNewLabel.setBounds(0, 0, 112, 53);
		panel.add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("\u5B66\u751F\u59D3\u540D");
		lblNewLabel_1.setFont(new Font("宋体", Font.PLAIN, 20));
		lblNewLabel_1.setBounds(31, 119, 117, 38);
		contentPane.add(lblNewLabel_1);
		
		JLabel lblNewLabel_1_1 = new JLabel("java\u6210\u7EE9");
		lblNewLabel_1_1.setFont(new Font("宋体", Font.PLAIN, 20));
		lblNewLabel_1_1.setBounds(31, 165, 117, 38);
		contentPane.add(lblNewLabel_1_1);
		
		JLabel lblNewLabel_1_2 = new JLabel("\u6570\u5B66\u6210\u7EE9");
		lblNewLabel_1_2.setFont(new Font("宋体", Font.PLAIN, 20));
		lblNewLabel_1_2.setBounds(31, 216, 117, 38);
		contentPane.add(lblNewLabel_1_2);
		
		JLabel lblNewLabel_1_3 = new JLabel("\u6570\u636E\u7ED3\u6784");
		lblNewLabel_1_3.setFont(new Font("宋体", Font.PLAIN, 20));
		lblNewLabel_1_3.setBounds(31, 267, 117, 38);
		contentPane.add(lblNewLabel_1_3);
		
		JLabel lblNewLabel_1_4 = new JLabel("\u82F1\u8BED\u6210\u7EE9");
		lblNewLabel_1_4.setFont(new Font("新宋体", Font.PLAIN, 20));
		lblNewLabel_1_4.setBounds(31, 318, 117, 38);
		contentPane.add(lblNewLabel_1_4);
		
		xueshengtextField = new JTextField();
		xueshengtextField.setBounds(170, 130, 373, 24);
		contentPane.add(xueshengtextField);
		xueshengtextField.setColumns(10);
		xueshengtextField.setText("此处输入修改后的学生姓名...");
		
		javatextField_1 = new JTextField();
		javatextField_1.setColumns(10);
		javatextField_1.setBounds(170, 179, 373, 24);
		contentPane.add(javatextField_1);
		
		shuxuetextField_2 = new JTextField();
		shuxuetextField_2.setColumns(10);
		shuxuetextField_2.setBounds(170, 225, 373, 24);
		contentPane.add(shuxuetextField_2);
		
		shujujiegoutextField_3 = new JTextField();
		shujujiegoutextField_3.setColumns(10);
		shujujiegoutextField_3.setBounds(170, 276, 373, 24);
		contentPane.add(shujujiegoutextField_3);
		
		yingyutextField_4 = new JTextField();
		yingyutextField_4.setColumns(10);
		yingyutextField_4.setBounds(170, 327, 373, 24);
		contentPane.add(yingyutextField_4);
		
		JButton btnNewButton = new JButton("\u786E\u8BA4\u4FEE\u6539");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			xiugai(e);
			}
		});

		Border bored = BorderFactory.createLineBorder(new Color(30, 144, 255));
		btnNewButton.setBorder(bored);

		btnNewButton.setFont(new Font("宋体", Font.PLAIN, 20));
		btnNewButton.setFocusPainted(false);
		btnNewButton.setForeground(new Color(30, 144, 255));
		btnNewButton.setBackground(new Color(255, 255, 255));
		btnNewButton.setBounds(196, 427, 127, 38);
		contentPane.add(btnNewButton);
		
		JButton btnNewButton_1 = new JButton("\u91CD\u65B0\u8F93\u5165");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				qingkong(e);
			}
		});
		btnNewButton_1.setBorder(bored);
		btnNewButton_1.setForeground(new Color(30, 144, 255));
		btnNewButton_1.setFont(new Font("宋体", Font.PLAIN, 20));
		btnNewButton_1.setFocusPainted(false);
		btnNewButton_1.setBackground(Color.WHITE);
		btnNewButton_1.setBounds(519, 427, 127, 38);
		contentPane.add(btnNewButton_1);
		
		JLabel lblNewLabel_1_5 = new JLabel("\u5B66\u751F\u59D3\u540D");
		lblNewLabel_1_5.setFont(new Font("宋体", Font.PLAIN, 20));
		lblNewLabel_1_5.setBounds(31, 79, 117, 38);
		contentPane.add(lblNewLabel_1_5);
		
		jiutextField = new JTextField();
		jiutextField.setBounds(170, 88, 373, 24);
		contentPane.add(jiutextField);
		jiutextField.setColumns(10);
		jiutextField.setText("此处输入要修改的学生姓名...");
	}

	protected void xiugai(ActionEvent e) {
	
		int a =0;
		daoimp cs = new daoimp();
		if(StringUtils.isNullOrEmpty(xueshengtextField.getText())||StringUtils.isNullOrEmpty(javatextField_1.getText())||StringUtils.isNullOrEmpty(shuxuetextField_2.getText())||StringUtils.isNullOrEmpty(shujujiegoutextField_3.getText())||StringUtils.isNullOrEmpty(yingyutextField_4.getText())||StringUtils.isNullOrEmpty(jiutextField.getText()))
			b.setVisible(true);
		double javas=Double.parseDouble(javatextField_1.getText());
		double shuxues =Double.parseDouble(shuxuetextField_2.getText());
		double shujujiegous = Double.parseDouble(shujujiegoutextField_3.getText());
		double yingyus  =Double.parseDouble (yingyutextField_4.getText());


		
		a = cs.remove(jiutextField.getText());
		if(a!=0){
		cs.add(xueshengtextField.getText(), javas, shuxues, shujujiegous,yingyus);
		t.setVisible(true);
		dispose();

		}
		else {
		m.setVisible(true);
		}

		
			
			}		


	protected void qingkong(ActionEvent e) {
		xueshengtextField.setText("");
		javatextField_1.setText("");
		shuxuetextField_2.setText("");;
		shujujiegoutextField_3.setText("");;
		yingyutextField_4.setText("");;
		
	}
	


}


view.select查询界面
public class select extends JFrame {

	bunengweikong b = new bunengweikong();
	meiyoushuju m = new meiyoushuju();
	private JPanel contentPane;
	private JTable table;
	private JTextField chaozhaotextField;

public static void main(String[] args) {
	select a = new select();
	
}

	/**
	 * Create the frame.
	 */
	public select() {
		setUndecorated(true);
		setBackground(Color.WHITE);


		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 800, 525);
		setLocation(600,238);
		setVisible(true);
		contentPane = new JPanel();
		contentPane.setBackground(Color.WHITE);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBackground(new Color(30, 144, 255));
		panel.setBounds(0, 0, 800, 60);
		contentPane.add(panel);
		panel.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("\u67E5\u627E");
		lblNewLabel.setForeground(Color.WHITE);
		lblNewLabel.setFont(new Font("宋体", Font.PLAIN, 30));
		lblNewLabel.setBounds(0, 0, 112, 53);
		panel.add(lblNewLabel);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setOpaque(false);
		scrollPane.getViewport().setOpaque(false);

		scrollPane.setBounds(0, 60, 585, 465);
		contentPane.add(scrollPane);
		
		table = new JTable();
		table.getTableHeader().setBackground(Color.WHITE);

		table.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"\u6392\u540D", "\u59D3\u540D", "java", "\u6570\u5B66", "\u6570\u636E\u7ED3\u6784", "\u82F1\u8BED", "\u5E73\u5747", "\u603B\u5206"
			}
		));
		
		scrollPane.setViewportView(table);
		
		JButton btnNewButton = new JButton("\u7EFC\u5408\u6392\u540D");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					chaozhaosuoyou(e);
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		btnNewButton.setForeground(new Color(30, 144, 255));
		Border bored = BorderFactory.createLineBorder(new Color(30, 144, 255));
		btnNewButton.setBorder(bored);

		btnNewButton.setFont(new Font("宋体", Font.PLAIN, 20));
		btnNewButton.setFocusPainted(false);
		btnNewButton.setBackground(Color.WHITE);
		btnNewButton.setBounds(622, 73, 127, 38);
		contentPane.add(btnNewButton);
		
		JLabel lblNewLabel_1 = new JLabel("\u8F93\u5165\u8981\u67E5\u627E\u7684\u59D3\u540D\uFF1A");
		lblNewLabel_1.setForeground(Color.BLACK);
		lblNewLabel_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
		lblNewLabel_1.setBounds(618, 383, 148, 53);
		contentPane.add(lblNewLabel_1);
		
		chaozhaotextField = new JTextField();
		chaozhaotextField.setBorder(bored);
		chaozhaotextField.setColumns(10);
		chaozhaotextField.setBounds(622, 436, 120, 38);
		contentPane.add(chaozhaotextField);
		
		JButton btnNewButton_1 = new JButton("\u786E\u8BA4\u67E5\u627E");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				chaozhaoxingming(e);
			}
		});
		btnNewButton_1.setBorder(bored);

		btnNewButton_1.setForeground(new Color(30, 144, 255));
		btnNewButton_1.setFont(new Font("宋体", Font.PLAIN, 20));
		btnNewButton_1.setFocusPainted(false);
		btnNewButton_1.setBackground(Color.WHITE);
		btnNewButton_1.setBounds(620, 487, 127, 38);
		contentPane.add(btnNewButton_1);
		
		JButton btnJava = new JButton("java\u6392\u540D");
		btnJava.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				javapaiming(e);
			}
		});
		btnJava.setForeground(new Color(30, 144, 255));
		btnJava.setBorder(bored);

		btnJava.setFont(new Font("宋体", Font.PLAIN, 20));
		btnJava.setFocusPainted(false);
		btnJava.setBackground(Color.WHITE);
		btnJava.setBounds(622, 124, 127, 38);
		contentPane.add(btnJava);
		
		JButton btnNewButton_3 = new JButton("\u6570\u5B66\u6392\u540D");
		btnNewButton_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					shuxuepaiming(e);
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		btnNewButton_3.setBorder(bored);

		btnNewButton_3.setForeground(new Color(30, 144, 255));
		btnNewButton_3.setFont(new Font("宋体", Font.PLAIN, 20));
		btnNewButton_3.setFocusPainted(false);
		btnNewButton_3.setBackground(Color.WHITE);
		btnNewButton_3.setBounds(622, 175, 127, 38);
		contentPane.add(btnNewButton_3);
		
		JButton btnNewButton_4 = new JButton("\u6570\u636E\u7ED3\u6784\u6392\u540D");
		btnNewButton_4.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					shujujiegoupaiming(e);
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		btnNewButton_4.setBorder(bored);

		btnNewButton_4.setForeground(new Color(30, 144, 255));
		btnNewButton_4.setFont(new Font("宋体", Font.PLAIN, 15));
		btnNewButton_4.setFocusPainted(false);
		btnNewButton_4.setBackground(Color.WHITE);
		btnNewButton_4.setBounds(622, 226, 127, 38);
		contentPane.add(btnNewButton_4);
		
		JButton btnNewButton_5 = new JButton("\u82F1\u8BED\u6392\u540D");
		btnNewButton_5.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					yingyupaiming(e);
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		btnNewButton_5.setBorder(bored);

		btnNewButton_5.setForeground(new Color(30, 144, 255));
		btnNewButton_5.setFont(new Font("宋体", Font.PLAIN, 20));
		btnNewButton_5.setFocusPainted(false);
		btnNewButton_5.setBackground(Color.WHITE);
		btnNewButton_5.setBounds(622, 277, 127, 38);
		contentPane.add(btnNewButton_5);
		
		JButton btnNewButton_2 = new JButton("\u5173\u95ED\u7A97\u53E3");
		btnNewButton_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});
		btnNewButton_2.setForeground(new Color(30, 144, 255));
		btnNewButton_2.setFont(new Font("宋体", Font.PLAIN, 20));
		btnNewButton_2.setFocusPainted(false);
		btnNewButton_2.setBackground(Color.WHITE);
		btnNewButton_2.setBounds(622, 332, 127, 38);
		contentPane.add(btnNewButton_2);
		btnNewButton_2.setBorder(bored);

	}

	protected void chaozhaoxingming(ActionEvent e) {

		daoimp da = new daoimp();
		if(StringUtils.isNullOrEmpty(chaozhaotextField.getText()))
			b.setVisible(true);
 		else {
			student a = da.selectName(chaozhaotextField.getText());
			if(a==null) {
				m.setVisible(true);
			}

		DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
		tableModel.setRowCount(0);

		Object[] o={a.getName(),a.getJava(),a.getMath(),a.getDatastruct(),a.getEnglish(),a.getAverage(),a.getTotal()};
		
		tableModel.addRow(o);
		}	
	}

	protected void yingyupaiming(ActionEvent e) throws SQLException {
		daoimp d = new daoimp();
		DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
		tableModel.setRowCount(0);
		List<student> a = d.sortenglish();
		d.removeall();
		d.chongxinbaocun(a);
		List<student> c = d.sortenglish();	
	     for(student vector : c){
             String[] t = {String.valueOf(vector.getPaiming()),vector.getName(),String.valueOf(vector.getJava()),String.valueOf(vector.getMath()),String.valueOf(vector.getDatastruct()),String.valueOf(vector.getEnglish()),String.valueOf(vector.getAverage()),String.valueOf(vector.getTotal())};
          tableModel.addRow(t);
      }							
	}

	protected void shujujiegoupaiming(ActionEvent e) throws SQLException {
		daoimp d = new daoimp();
		DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
		tableModel.setRowCount(0);
		List<student> a = d.sortdatastruct();
		d.removeall();
		d.chongxinbaocun(a);
		List<student> c = d.sortdatastruct();
		for(student vector : c){
             String[] t = {String.valueOf(vector.getPaiming()),vector.getName(),String.valueOf(vector.getJava()),String.valueOf(vector.getMath()),String.valueOf(vector.getDatastruct()),String.valueOf(vector.getEnglish()),String.valueOf(vector.getAverage()),String.valueOf(vector.getTotal())};
          tableModel.addRow(t);
      }					
	}

	protected void shuxuepaiming(ActionEvent e) throws SQLException {
		daoimp d = new daoimp();
		DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
		tableModel.setRowCount(0);
		List<student> a = d.sortmath();
		d.removeall();
		d.chongxinbaocun(a);
		List<student> c = d.sortmath();
	     for(student vector :  c){
             String[] t = {String.valueOf(vector.getPaiming()),vector.getName(),String.valueOf(vector.getJava()),String.valueOf(vector.getMath()),String.valueOf(vector.getDatastruct()),String.valueOf(vector.getEnglish()),String.valueOf(vector.getAverage()),String.valueOf(vector.getTotal())};
          tableModel.addRow(t);
      }			
	}

	protected void javapaiming(ActionEvent e) {
		daoimp d = new daoimp();
		DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
		tableModel.setRowCount(0);
		List<student> a = d.sortjava();
		d.removeall();
		d.chongxinbaocun(a);
		List<student> c = d.sortjava();
	     for(student vector : c){
             String[] t = {String.valueOf(vector.getPaiming()),vector.getName(),String.valueOf(vector.getJava()),String.valueOf(vector.getMath()),String.valueOf(vector.getDatastruct()),String.valueOf(vector.getEnglish()),String.valueOf(vector.getAverage()),String.valueOf(vector.getTotal())};
          tableModel.addRow(t);
      }		
	}		
	

	protected void chaozhaosuoyou(ActionEvent e) throws SQLException {
		daoimp d = new daoimp();
		DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
		tableModel.setRowCount(0);
		List<student> a = d.sortzongfen();
		d.removeall();
		d.chongxinbaocun(a);
		List<student> c = d.sortzongfen();		
	     for(student vector : c){
             String[] t = {String.valueOf(vector.getPaiming()),vector.getName(),String.valueOf(vector.getJava()),String.valueOf(vector.getMath()),String.valueOf(vector.getDatastruct()),String.valueOf(vector.getEnglish()),String.valueOf(vector.getAverage()),String.valueOf(vector.getTotal())};
          tableModel.addRow(t);
      }		
	}
}
//查询界面代码比较多 因为要涉及到各个科目的排名和总成绩的排名

最后

如果你使用了windowbuilder这个插件一定要主要不能完全依赖这个插件,你需要以这个插件为辅助增添或者是设置位置大小等,但大多数的美化功能等都是需要代码来添加的,简约的界面需要用到大量的透明设置,还有边框设置这些在代码中都有体现,windobuilder可能实现不了,只能加代码。有个bug就是使用JTable的时候先加JTable在右击他包上scrollPane,这样才行。还有操作的时候一定要全面屏界面不然很容易崩溃掉。

使用该程序或者是想要学习更简单的课设

如果你想要使用该程序或者是学习,请评论你不懂的地方或者私信我,我会回复的,还有这个程序包含许多图片,需要自行下载。

你可能感兴趣的:(java课设,jdbc,mysql,java,swing,数据库)