学生的信息 学号,姓名,数学成绩,英语成绩,数据库成绩,java成绩
第一步:在MyStudent中添加相应代码,做出学生成绩窗口
第二步:写一个TeacherAll窗口(点击查询全部信息时可以弹出来)
第三步:关联数据库
学生成绩窗口
package sias1;
import java.awt.Container;
import java.sql.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
/*
* zuozhe:hanfuyan
* qishishijian:2021年4月09日22:15:20
* jiezhishijian:2021年4月15日09:11:38
* */
public class MyTeacher extends JFrame{
JLabel labelsno;
JTextField textsno;
JLabel labelname;
JTextField textname;
JLabel labelmath;
JTextField textmath;
JLabel labelenglish;
JTextField textenglish;
JLabel labeldata;
JTextField textdata;
JLabel labeljava;
JTextField textjava;
JButton button1;
JButton button2;
JButton button3;
JButton button4;
public MyTeacher() {
setTitle("学生成绩窗口");
setSize(600,400);
setResizable(false);
ImageIcon icon1 = new ImageIcon("image1\\kdy.jpg");
Image image0 = icon1.getImage();
setIconImage(image0);
GridBagLayout gb1 = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
labelsno = new JLabel("学号");
textsno = new JTextField(15);
labelname = new JLabel("姓名");
textname = new JTextField(15);
labelmath = new JLabel("数学成绩");
textmath = new JTextField(15);
labeldata = new JLabel("数据库成绩");
textdata = new JTextField(15);
labelenglish = new JLabel("英语成绩");
textenglish = new JTextField(15);
labeljava = new JLabel("Java成绩");
textjava = new JTextField(15);
button1 = new JButton("保存");
button2 = new JButton("查询");
button3 = new JButton("取消");
button4 = new JButton("查询全部");
Container c1 = getContentPane();
c1.setLayout(gb1);//采用网格包布局
gbc.gridy = 1;
gbc.gridx = 1;
gbc.gridheight = 1;
gbc.gridwidth = 1;
gbc.weighty = 1;
gbc.weightx =1;
gb1.setConstraints(labelsno,gbc);
c1.add(labelsno);
gbc.gridy = 1;
gbc.gridx = 2;
gbc.gridheight = 1;
gbc.gridwidth = 1;
gbc.weighty = 1;
gbc.weightx =1;
gb1.setConstraints(textsno,gbc);
c1.add(textsno);
gbc.gridy = 1;
gbc.gridx = 3;
gbc.gridheight = 1;
gbc.gridwidth = 1;
gbc.weighty = 1;
gbc.weightx =1;
gb1.setConstraints(labelname,gbc);
c1.add(labelname);
gbc.gridy = 1;
gbc.gridx = 4;
gbc.gridheight = 1;
gbc.gridwidth = 1;