📄 jpanel2.java
字号:
package guanlixitong;
import java.awt.*;
import javax.swing.*;
import java.awt.Rectangle;
import java.awt.Font;
import java.awt.event.*;
import javax.swing.border.*;
import java.sql.*;
public class JPanel2
extends JPanel implements ActionListener {
mark[] mar = new mark[5];
Student std = new Student();
boolean bool = false;
public JPanel2() {
try {
jbInit();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
private void jbInit() throws Exception {
titledBorder1 = new TitledBorder("");
titledBorder2 = new TitledBorder("");
this.setLayout(null);
jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 15));
jLabel1.setForeground(Color.magenta);
jLabel1.setText("姓 名");
jLabel1.setBounds(new Rectangle(113, 95, 80, 26));
jTextField1.setEditable(true);
jTextField1.setBounds(new Rectangle(226, 320, 90, 25));
jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 15));
jLabel2.setForeground(Color.magenta);
jLabel2.setText("成 绩2");
jLabel2.setBounds(new Rectangle(113, 185, 79, 27));
jLabel3.setFont(new java.awt.Font("宋体", Font.PLAIN, 15));
jLabel3.setForeground(Color.magenta);
jLabel3.setText("成 绩1");
jLabel3.setBounds(new Rectangle(113, 140, 79, 27));
jLabel4.setFont(new java.awt.Font("宋体", Font.PLAIN, 15));
jLabel4.setForeground(Color.magenta);
jLabel4.setText("成 绩3");
jLabel4.setBounds(new Rectangle(113, 230, 79, 27));
jLabel5.setFont(new java.awt.Font("宋体", Font.PLAIN, 15));
jLabel5.setForeground(Color.magenta);
jLabel5.setText("成 绩4");
jLabel5.setBounds(new Rectangle(113, 275, 79, 27));
jLabel6.setFont(new java.awt.Font("宋体", Font.PLAIN, 15));
jLabel6.setForeground(Color.magenta);
jLabel6.setText("学 号");
jLabel6.setBounds(new Rectangle(113, 50, 78, 32));
jLabel7.setFont(new java.awt.Font("宋体", Font.PLAIN, 15));
jLabel7.setForeground(Color.magenta);
jLabel7.setText("成 绩5");
jLabel7.setBounds(new Rectangle(113, 320, 79, 27));
jTextField2.setEnabled(true);
jTextField2.setEditable(true);
jTextField2.setBounds(new Rectangle(226, 275, 90, 25));
jTextField3.setBounds(new Rectangle(226, 230, 90, 25));
jTextField3.setEditable(true);
jTextField4.setEditable(true);
jTextField4.setBounds(new Rectangle(226, 185, 90, 25));
jTextField5.setEditable(true);
jTextField5.setBounds(new Rectangle(226, 140, 90, 25));
jTextField6.setEditable(true);
jTextField6.setBounds(new Rectangle(226, 50, 135, 25));
jTextField7.setEnabled(false);
jTextField7.setEditable(true);
jTextField7.setBounds(new Rectangle(226, 95, 90, 25));
jLabel10.setFont(new java.awt.Font("宋体", Font.PLAIN, 15));
jLabel10.setForeground(Color.magenta);
jLabel10.setText("平均成绩");
jLabel10.setBounds(new Rectangle(113, 365, 79, 27));
jTextField8.setEditable(true);
jTextField8.setText(" ");
jTextField8.setBounds(new Rectangle(227, 365, 90, 25));
jButton1.setBounds(new Rectangle(113, 420, 104, 30));
jButton1.setFont(new java.awt.Font("Dialog", 0, 15));
jButton1.setForeground(Color.magenta);
jButton1.setFocusPainted(true);
jButton1.setText("提 交");
jButton2.setText("查 询");
jButton2.setFocusPainted(true);
jButton2.setForeground(Color.magenta);
jButton2.setFont(new java.awt.Font("Dialog", 0, 15));
jButton2.setBounds(new Rectangle(259, 417, 104, 30));
jButton3.setBounds(new Rectangle(418, 415, 143, 30));
jButton3.setFont(new java.awt.Font("Dialog", 0, 15));
jButton3.setForeground(Color.magenta);
jButton3.setFocusPainted(true);
jButton3.setText("显示排名");
jButton1.addActionListener(this);
jButton2.addActionListener(this);
jButton3.addActionListener(this);
jCheckBox1.setEnabled(false);
jCheckBox1.setBorder(titledBorder1);
jCheckBox1.setBorderPainted(false);
jCheckBox1.setText("");
jCheckBox1.setBounds(new Rectangle(71, 140, 20, 21));
jCheckBox2.setBounds(new Rectangle(74, 185, 20, 21));
jCheckBox2.setEnabled(false);
jCheckBox2.setText("");
jCheckBox3.setBounds(new Rectangle(74, 230, 20, 21));
jCheckBox3.setEnabled(false);
jCheckBox3.setDebugGraphicsOptions(0);
jCheckBox3.setText("");
jCheckBox4.setBounds(new Rectangle(74, 275, 20, 21));
jCheckBox4.setEnabled(false);
jCheckBox4.setText("");
jCheckBox5.setBounds(new Rectangle(74, 320, 20, 21));
jCheckBox5.setEnabled(false);
jCheckBox5.setText("");
jLabel8.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel8.setForeground(Color.magenta);
jLabel8.setBounds(new Rectangle(344, 92, 272, 25));
jLabel9.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel9.setForeground(Color.magenta);
jLabel9.setText("");
jLabel9.setBounds(new Rectangle(345, 140, 59, 29));
jLabel11.setBounds(new Rectangle(415, 140, 59, 29));
jLabel11.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel11.setForeground(Color.magenta);
jLabel11.setText("");
jLabel12.setBounds(new Rectangle(490, 140, 59, 29));
jLabel12.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel12.setForeground(Color.magenta);
jLabel12.setText("");
jLabel13.setBounds(new Rectangle(560, 140, 59, 29));
jLabel13.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel13.setForeground(Color.magenta);
jLabel13.setText("");
jLabel14.setText("");
jLabel14.setForeground(Color.magenta);
jLabel14.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel14.setBounds(new Rectangle(345, 185, 59, 29));
jLabel15.setText("");
jLabel15.setForeground(Color.magenta);
jLabel15.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel15.setBounds(new Rectangle(415, 185, 59, 29));
jLabel16.setText("");
jLabel16.setForeground(Color.magenta);
jLabel16.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel16.setBounds(new Rectangle(490, 185, 59, 29));
jLabel17.setText("");
jLabel17.setForeground(Color.magenta);
jLabel17.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel17.setBounds(new Rectangle(560, 185, 59, 29));
jLabel18.setText("");
jLabel18.setForeground(Color.magenta);
jLabel18.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel18.setBounds(new Rectangle(345, 230, 59, 29));
jLabel19.setText("");
jLabel19.setForeground(Color.magenta);
jLabel19.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel19.setBounds(new Rectangle(415, 230, 59, 29));
jLabel110.setText("");
jLabel110.setForeground(Color.magenta);
jLabel110.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel110.setBounds(new Rectangle(490, 230, 59, 29));
jLabel111.setText("");
jLabel111.setForeground(Color.magenta);
jLabel111.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel111.setBounds(new Rectangle(560, 230, 59, 29));
jLabel112.setText("");
jLabel112.setForeground(Color.magenta);
jLabel112.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel112.setBounds(new Rectangle(345, 275, 59, 29));
jLabel113.setText("");
jLabel113.setForeground(Color.magenta);
jLabel113.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel113.setBounds(new Rectangle(415, 275, 59, 29));
jLabel114.setText("");
jLabel114.setForeground(Color.magenta);
jLabel114.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel114.setBounds(new Rectangle(490, 275, 59, 29));
jLabel115.setText("");
jLabel115.setForeground(Color.magenta);
jLabel115.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel115.setBounds(new Rectangle(560, 275, 59, 29));
jLabel116.setText("");
jLabel116.setForeground(Color.magenta);
jLabel116.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel116.setBounds(new Rectangle(345, 320, 59, 29));
jLabel117.setText("");
jLabel117.setForeground(Color.magenta);
jLabel117.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel117.setBounds(new Rectangle(415, 320, 59, 29));
jLabel118.setText("");
jLabel118.setForeground(Color.magenta);
jLabel118.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel118.setBounds(new Rectangle(490, 320, 59, 29));
jLabel119.setText("");
jLabel119.setForeground(Color.magenta);
jLabel119.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel119.setBounds(new Rectangle(560, 320, 59, 29));
jLabel20.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel20.setForeground(Color.red);
jLabel20.setBounds(new Rectangle(386, 51, 172, 24));
this.add(jTextField5);
this.add(jTextField4);
this.add(jTextField3);
this.add(jTextField2);
this.add(jTextField1);
this.add(jLabel3);
this.add(jLabel2);
this.add(jLabel5);
this.add(jLabel7);
this.add(jLabel4);
this.add(jLabel10);
this.add(jTextField8);
this.add(jLabel1);
this.add(jTextField6);
this.add(jTextField7);
this.add(jButton1, null);
this.add(jButton2, null);
this.add(jButton3, null);
this.add(jLabel6);
this.add(jCheckBox2, null);
this.add(jCheckBox3, null);
this.add(jCheckBox5, null);
this.add(jCheckBox4, null);
this.add(jLabel8, null);
this.add(jLabel9, null);
this.add(jLabel11, null);
this.add(jLabel13, null);
this.add(jLabel12, null);
this.add(jLabel14, null);
this.add(jLabel15, null);
this.add(jLabel16, null);
this.add(jLabel17, null);
this.add(jLabel18, null);
this.add(jLabel19, null);
this.add(jLabel110, null);
this.add(jLabel111, null);
this.add(jLabel112, null);
this.add(jLabel113, null);
this.add(jLabel114, null);
this.add(jLabel115, null);
this.add(jLabel116, null);
this.add(jLabel117, null);
this.add(jLabel118, null);
this.add(jLabel119, null);
this.add(jCheckBox1, null);
this.add(jLabel20, null);
}
public void make() {
jTextField2.setText(Integer.toString(std.成绩4));
jTextField3.setText(Integer.toString(std.成绩3));
jTextField4.setText(Integer.toString(std.成绩2));
jTextField5.setText(Integer.toString(std.成绩1));
jTextField1.setText(Integer.toString(std.成绩5));
jTextField6.setText(Integer.toString(std.学号));
jTextField7.setText(std.姓名);
jTextField8.setText(Double.toString(std.平均成绩));
}
JLabel jLabel1 = new JLabel();
JTextField jTextField1 = new JTextField();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JLabel jLabel5 = new JLabel();
JLabel jLabel6 = new JLabel();
JLabel jLabel7 = new JLabel();
JTextField jTextField2 = new JTextField();
JTextField jTextField3 = new JTextField();
JTextField jTextField4 = new JTextField();
JTextField jTextField5 = new JTextField();
JTextField jTextField6 = new JTextField();
JTextField jTextField7 = new JTextField();
JLabel jLabel10 = new JLabel();
JTextField1 jTextField8 = new JTextField1();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JCheckBox jCheckBox1 = new JCheckBox();
JCheckBox jCheckBox2 = new JCheckBox();
JCheckBox jCheckBox3 = new JCheckBox();
JCheckBox jCheckBox4 = new JCheckBox();
JCheckBox jCheckBox5 = new JCheckBox();
JLabel jLabel8 = new JLabel();
JLabel jLabel9 = new JLabel();
JLabel jLabel11 = new JLabel();
JLabel jLabel12 = new JLabel();
JLabel jLabel13 = new JLabel();
JLabel jLabel14 = new JLabel();
JLabel jLabel15 = new JLabel();
JLabel jLabel16 = new JLabel();
JLabel jLabel17 = new JLabel();
JLabel jLabel18 = new JLabel();
JLabel jLabel19 = new JLabel();
JLabel jLabel110 = new JLabel();
JLabel jLabel111 = new JLabel();
JLabel jLabel112 = new JLabel();
JLabel jLabel113 = new JLabel();
JLabel jLabel114 = new JLabel();
JLabel jLabel115 = new JLabel();
JLabel jLabel116 = new JLabel();
JLabel jLabel117 = new JLabel();
JLabel jLabel118 = new JLabel();
JLabel jLabel119 = new JLabel();
TitledBorder titledBorder1;
TitledBorder titledBorder2;
JLabel jLabel20 = new JLabel();
public void actionPerformed(ActionEvent e) {
jLabel20.setText("");
jLabel8.setText("");
jLabel9.setText("");
jLabel11.setText("");
jLabel12.setText("");
jLabel13.setText("");
jLabel14.setText("");
jLabel15.setText("");
jLabel16.setText("");
jLabel17.setText("");
jLabel18.setText("");
jLabel19.setText("");
jLabel110.setText("");
jLabel111.setText("");
jLabel112.setText("");
jLabel113.setText("");
jLabel114.setText("");
jLabel115.setText("");
jLabel116.setText("");
jLabel117.setText("");
jLabel118.setText("");
jLabel119.setText("");
if (e.getSource() == jButton1) {
jCheckBox1.setEnabled(true);
jCheckBox2.setEnabled(true);
jCheckBox3.setEnabled(true);
jCheckBox4.setEnabled(true);
jCheckBox5.setEnabled(true);
jCheckBox1.setSelected(false);
jCheckBox2.setSelected(false);
jCheckBox3.setSelected(false);
jCheckBox4.setSelected(false);
jCheckBox5.setSelected(false);
String str = "jdbc:odbc:yangAcess";
Connection con;
String num="0";
if(!jTextField6.getText().equals(""))
num= jTextField6.getText().trim();
int num1 = 0;
String sSelect = "select 姓名,成绩1,成绩2,成绩3,成绩4,成绩5,学号 from yang1 where 学号=" +
Integer.parseInt(num);
ResultSet rs;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection(str);
Statement stmt = con.createStatement();
rs = stmt.executeQuery(sSelect);
while (rs.next()) {
std.姓名 = rs.getString("姓名");
std.成绩1 = rs.getInt("成绩1");
std.成绩2 = rs.getInt("成绩2");
std.成绩3 = rs.getInt("成绩3");
std.成绩4 = rs.getInt("成绩4");
std.成绩5 = rs.getInt("成绩5");
std.学号 = rs.getInt("学号");
}
con.close();
stmt.close();
}
catch (Exception ae) {
System.out.print("Woring");
}
if (std.学号 != Integer.parseInt(num)) {
getDate();
insert();
}
else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -