日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > windows >内容正文

windows

分数统计设计java程序_(windows综合程序)设计一个学生平时成绩统计软件 最后的Java作业...

發(fā)布時(shí)間:2024/3/13 windows 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 分数统计设计java程序_(windows综合程序)设计一个学生平时成绩统计软件 最后的Java作业... 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1、(windows綜合程序)設(shè)計(jì)一個(gè)學(xué)生平時(shí)成績(jī)統(tǒng)計(jì)軟件。要求:

(1) 錄入課程名稱(chēng)(進(jìn)入系統(tǒng)時(shí)錄入)、學(xué)生姓名、學(xué)號(hào)、成績(jī)、日期(自動(dòng)生成日期并在界面顯示),除第一次外其他次數(shù)輸入只需要錄入學(xué)號(hào)、成績(jī),其他自動(dòng)產(chǎn)生,錄入要求所有項(xiàng)目不能為空,界面設(shè)計(jì)自己定義,每錄入一筆記錄暫時(shí)放在內(nèi)存,當(dāng)點(diǎn)擊按鈕保存時(shí)再寫(xiě)入數(shù)據(jù)庫(kù)。每次只能錄入一次的學(xué)生平時(shí)成績(jī)(同一日期,所有學(xué)生的成績(jī))

(2) 數(shù)據(jù)庫(kù)端建立數(shù)據(jù)庫(kù)表(第一次錄入課程名稱(chēng)時(shí)創(chuàng)建以課程名為名字的表),含字段:學(xué)號(hào)、姓名、第一次平時(shí)成績(jī)、第二次次平時(shí)成績(jī)(共10次成績(jī))、平時(shí)平均成績(jī)(自動(dòng)計(jì)算)

(3) 查詢和瀏覽學(xué)生平時(shí)成績(jī),要求:

① 查詢平時(shí)成績(jī)時(shí)只要錄入學(xué)號(hào)則顯示窗體顯示:姓名、學(xué)號(hào)、目前為止平均平時(shí)成績(jī)。

② 瀏覽學(xué)生成績(jī)時(shí)呀求逐筆學(xué)生記錄顯示學(xué)生成績(jī),每次按按紐‘下一筆’時(shí)顯示下一位學(xué)生的成績(jī)

(4) 生成學(xué)生平時(shí)成績(jī)EXECL表,將數(shù)據(jù)庫(kù)中的學(xué)生成績(jī)生成一個(gè)表格放在本地(這項(xiàng)不要求每位同學(xué)做,愿意做的可以查找相關(guān)資料后做)

其他在上面沒(méi)有提出的自己確定,包括界面形式等,只要能夠讓系統(tǒng)達(dá)到上述要求即可。

以下是我的源代碼:

package endtest;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.SQLException;

import java.sql.Statement;

import java.sql.*;

import java.text.SimpleDateFormat;

import java.time.LocalDate;

import java.util.Calendar;

import java.util.Date;

import java.util.Scanner;

public class myjdbc {

private static final String url = "jdbc:mysql://localhost:3306/student?useSSL=false&serverTimezone=UTC";

private static final String name = "com.mysql.cj.jdbc.Driver";

private static final String user = "root";

private static final String password = "06101010lu";

private Connection conn = null;

private Statement pst = null;

public void getDataBaseConnection(){

try{

Class.forName(name);

conn = DriverManager.getConnection(url, user, password);

System.out.println("已成功的與數(shù)據(jù)庫(kù)MySQL建立連接!!");

}catch(Exception e){

System.out.println("連接失敗!!");

e.printStackTrace();

}

}

public void init(){

try {

pst = conn.createStatement();

String sql = "CREATE TABLE IF NOT EXISTS register(USER VARCHAR(200),PWD VARCHAR(200))";

pst.executeUpdate(sql);

}catch (SQLException e) {

e.printStackTrace();

}

}

public void addUser(String user,String pwd){

System.out.println(user+" yy "+pwd);

try {

pst = conn.createStatement();

String sql = "INSERT INTO register(USER,PWD) values('"+user+"','"+pwd+"')";

pst.executeUpdate(sql);

System.out.println("yes");

}catch (SQLException e) {

System.out.println("fails!");

e.printStackTrace();

}

}

public boolean checkUser(String user,String pwd){

try {

pst = conn.createStatement();

String sql = "SELECT * FROM register WHERE USER = "+user+" AND PWD = "+pwd;

ResultSet ans = pst.executeQuery(sql);

if(ans.next()) return true;

return false;

}catch (SQLException e) {

e.printStackTrace();

}

return false;

}

public void close() {

try {

this.conn.close();

this.pst.close();

} catch (SQLException e) {

e.printStackTrace();

}

}

public void creatMyTable(String tableName) {

try{

System.out.println("請(qǐng)輸入課程名稱(chēng):"+tableName+" ");

pst = conn.createStatement();

String sql = "CREATE TABLE IF NOT EXISTS "

+ tableName

+"(ID VARCHAR(200),CNAME VARCHAR(200),SCORE FLOAT,CSUM FLOAT ,NUM FLOAT ,CTIME char(200))";

pst.executeUpdate(sql);

System.out.println("成功創(chuàng)建學(xué)生表!!!");

}catch(SQLException e){

e.printStackTrace();

}

}

public boolean checkTable(String tableName){

try {

System.out.println("fd:"+tableName);

ResultSet ans = conn.getMetaData().getTables(null, null, tableName, null );

if(ans.next()) return true;

return false;

} catch (SQLException e) {

e.printStackTrace();

}

return false;

}

public void saveMyTable(String tableName,String name,String id,float score) {

try {

LocalDate date = LocalDate.now(); // get the current date

String time = date.toString();

System.out.println(date+" "+time);

pst = conn.createStatement();

String sql1 = "SELECT * FROM " + tableName + " WHERE ID="+id;

ResultSet ans = pst.executeQuery(sql1);

float sum = score,num = 1.0f;

if(ans.next()){

sum +=ans.getFloat("CSUM");

num +=ans.getFloat("NUM");

score = sum / num;

}

sql1 = "DELETE FROM "+ tableName + " WHERE ID="+id;

pst.executeUpdate(sql1);

System.out.println(score + " "+ sum+" "+" "+num);

String sql ="INSERT INTO "

+tableName

+"(ID,CNAME,SCORE,CSUM,NUM,CTIME) VALUES('"+id+"','"+name+"',"+score+","+sum+","+num+",'"+time+"')";

pst.executeUpdate(sql);// 返回影響的記錄行數(shù)

} catch (SQLException e) {

e.printStackTrace();

}

}

public void QueryStudent(String sc,String idn,String[] ans) {

try{

System.out.println(sc+" --- "+idn+" --- ");

pst = conn.createStatement();

String sql = "SELECT * FROM "+sc+" WHERE ID= "+idn;

ResultSet rc = pst.executeQuery(sql);

System.out.println("true!!!");

// 展開(kāi)結(jié)果集數(shù)據(jù)庫(kù)

if(rc.next()){

// 通過(guò)字段檢索

ans[0] = rc.getString("ID");

ans[1] = rc.getString("CNAME");

float score = rc.getInt("SCORE");

ans[2] = Float.toString(score);

}

}catch(SQLException e) {

e.printStackTrace();

}

}

public String[][] DisplayStudent(String sc) {

try{

int now=0;

String [][] res = new String[10000][3];

pst = conn.createStatement();

String sql = "SELECT * FROM "+ sc;

ResultSet rc = pst.executeQuery(sql);

// 展開(kāi)結(jié)果集數(shù)據(jù)庫(kù)

System.out.println("所有學(xué)生集合:");

while(rc.next()){

// 通過(guò)字段檢索

res[now][0] = rc.getString("ID");

res[now][1] = rc.getString("CNAME");

float score = rc.getInt("SCORE");

res[now][2] = Float.toString(score);

now++;

}

String [][] ans;

if(now==0){

ans = new String[1][3];

ans[0][0]=ans[0][1]=ans[0][2]="此為空表!";

}

else{

ans = new String[now][3];

for(int i=0;i

ans[i]=res[i];

}

}

return ans;

}catch(SQLException e) {

e.printStackTrace();

}

return new String[0][0];

}

}

package endtest;

import javax.swing.*;

import java.awt.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.geom.AffineTransform;

public class test {

public static void main(String[] args){

myjdbc jdbc = new myjdbc();

jdbc.getDataBaseConnection();

jdbc.init();

JFrame frame = new JFrame("學(xué)生平時(shí)成績(jī)統(tǒng)計(jì)系統(tǒng)");

frame.setVisible(true);

frame.setBounds(300,200,600,400);

JPanel panel = new JPanel();

frame.add(panel);

//采用自定義設(shè)置,只有這樣,JLabel才可以自定義在JPanel中的位置,不然JLevel是居中顯示

panel.setLayout(null);

Font font = new Font("微軟雅黑", Font.BOLD,18);

JLabel user_lab = new JLabel("用戶名:");

user_lab.setFont(font);

user_lab.setBounds(110,20,100,100);

panel.add(user_lab);

//創(chuàng)建輸入的文本框

JTextField user_Field = new JTextField();

user_Field.setBounds(200,60,160,30);

panel.add(user_Field);

user_lab.setBackground(Color.white);

//創(chuàng)建輸入的密碼框

JLabel pwd = new JLabel("密碼:");

pwd.setFont(font);

pwd.setBounds(110,100,160,30);

panel.add(pwd);

JPasswordField pwd_Field = new JPasswordField();

pwd_Field.setBounds(200,100,160,30);

pwd.setBackground(Color.white);

panel.add(pwd_Field);

JButton login = new JButton("登錄");

login.setBounds(180,150,80,30);

panel.add(login);

JButton register = new JButton("注冊(cè)");

register.setBounds(278,150,80,30);

panel.add(register);

register.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

//獲取文本值的api

JPanel RegisterPanel = new JPanel();

RegisterPanel.setLayout(null);

JLabel user = new JLabel("用戶名:");

user.setFont(font);

user.setBounds(110,20,100,100);

RegisterPanel.add(user);

//創(chuàng)建輸入的文本框

JTextField user_F = new JTextField();

user_F.setBounds(200,60,160,30);

RegisterPanel.add(user_F);

user.setBackground(Color.white);

//創(chuàng)建第一個(gè)輸入的密碼框

JLabel FirPwd = new JLabel("密碼:");

FirPwd.setFont(font);

FirPwd.setBounds(110,100,160,30);

RegisterPanel.add(FirPwd);

JPasswordField FirPwdField = new JPasswordField();

FirPwdField.setBounds(200,100,160,30);

FirPwd.setBackground(Color.white);

RegisterPanel.add(FirPwdField);

//創(chuàng)建第二個(gè)輸入的密碼框

JLabel SecPwd = new JLabel("確認(rèn)密碼:");

SecPwd.setFont(font);

SecPwd.setBounds(110,140,160,30);

RegisterPanel.add(SecPwd);

JPasswordField SecPwdField = new JPasswordField();

SecPwdField.setBounds(200,140,160,30);

SecPwd.setBackground(Color.white);

RegisterPanel.add(SecPwdField);

JButton reg = new JButton("注冊(cè)");

reg.setBounds(278,190,80,30);

RegisterPanel.add(reg);

JButton back = new JButton("返回");

back.setBounds(180,190,80,30);

RegisterPanel.add(back);

panel.setVisible(false);

frame.add(RegisterPanel);

back.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

panel.setVisible(true);

RegisterPanel.setVisible(false);

}

});

reg.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

String user = user_F.getText().trim();

String pwd1 = FirPwdField.getText().trim();

String pwd2 = SecPwdField.getText().trim();

if(pwd1.equals(pwd2)&&!user.equals("")&&!pwd1.equals("")){

jdbc.addUser(user,pwd1);

frame.setVisible(false);

choose(jdbc);

}

else{

System.out.println("ssss help");

JFrame error = new JFrame("輸入錯(cuò)誤!!!");

error.setBounds(200,200,400,100);

JPanel er = new JPanel();

er.setLayout(null);

JLabel tip = new JLabel("兩次密碼輸入不同!或者用戶名為null!");

tip.setBounds(10,0,350,30);

JButton reback = new JButton("返回");

reback.setBounds(170,30,60,20);

er.add(tip);

er.add(reback);

error.add(er);

error.setVisible(true);

reback.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

error.setVisible(false);

panel.setVisible(true);

}

});

}

}

});

}

});

login.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

//獲取文本值的api

String username = user_Field.getText().trim();

String password = pwd_Field.getText().trim();

if(!password.equals("")&&!username.equals("")&&jdbc.checkUser(username,password)){

frame.setVisible(false);

choose(jdbc);

}

else {

JFrame error = new JFrame("密碼錯(cuò)誤");

error.setBounds(200,200,400,100);

JPanel er = new JPanel();

er.setLayout(null);

JLabel tip = new JLabel("賬號(hào)不存在或密碼錯(cuò)誤!");

tip.setBounds(10,0,350,30);

JButton reback = new JButton("返回");

reback.setBounds(170,30,60,20);

er.add(tip);

er.add(reback);

error.add(er);

error.setVisible(true);

reback.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

error.setVisible(false);

}

});

}

}

});

}

public static void choose(myjdbc jdbc){

JFrame frame = new JFrame("學(xué)生平時(shí)成績(jī)統(tǒng)計(jì)系統(tǒng)");

frame.setVisible(true);

frame.setBounds(300,200,600,400);

JPanel panel = new JPanel();

frame.add(panel);

//采用自定義設(shè)置,只有這樣,JLabel才可以自定義在JPanel中的位置,不然JLevel是居中顯示

panel.setLayout(null);

Font font = new Font("微軟雅黑", Font.BOLD,14);

JButton first = new JButton("建立表格");

first.setBounds(200,20,150,50);

first.setFont(font);

panel.add(first);

JButton other = new JButton("錄入成績(jī)");

other.setBounds(200,100,150,50);

other.setFont(font);

panel.add(other);

JButton query = new JButton("查詢成績(jī)");

query.setBounds(200,180,150,50);

query.setFont(font);

panel.add(query);

JButton watch = new JButton("瀏覽成績(jī)");

watch.setBounds(200,260,150,50);

watch.setFont(font);

panel.add(watch);

first.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

panel.setVisible(false);

JPanel create = new JPanel();

create.setLayout(null);

frame.add(create);

JLabel Input = new JLabel("表格的名字:");

Input.setBounds(10,50,100,30);

Input.setFont(font);

create.add(Input);

JTextField input = new JTextField();

input.setBounds(120,50,200,30);

input.setFont(font);

create.add(input);

JButton back = new JButton("返回");

back.setFont(font);

back.setBounds(100,100,100,30);

create.add(back);

JButton submit = new JButton("提交");

submit.setFont(font);

submit.setBounds(220,100,100,30);

create.add(submit);

back.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

create.setVisible(false);

panel.setVisible(true);

}

});

submit.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

String c = input.getText().trim();

boolean f = false;

if(c.length() == 0) ;

else if(c.charAt(0)<='z'&&c.charAt(0)>='a') f = true;

else if(c.charAt(0)<='Z'&&c.charAt(0)>='A') f = true;

else if(c.charAt(0)=='_') f = true;

if(f&&!jdbc.checkTable(c)) {

jdbc.creatMyTable(c);

create.setVisible(false);

panel.setVisible(true);

}

else{

JFrame error = new JFrame("表格錯(cuò)誤");

error.setBounds(200,200,400,100);

JPanel er = new JPanel();

er.setLayout(null);

JLabel tip = new JLabel("表格名字不符合規(guī)范或表格已經(jīng)存在!!");

tip.setBounds(10,0,350,30);

JButton reback = new JButton("返回");

reback.setBounds(170,30,60,20);

er.add(tip);

er.add(reback);

error.add(er);

error.setVisible(true);

reback.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

error.setVisible(false);

}

});

}

}

});

}

});

other.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

panel.setVisible(false);

JPanel FPanel = new JPanel();

FPanel.setLayout(null);

frame.add(FPanel);

JLabel Course = new JLabel("課程:");

Course.setBounds(100,50,100,30);

Course.setFont(font);

FPanel.add(Course);

JTextField course = new JTextField();

course.setBounds(160,50,200,30);

FPanel.add(course);

JLabel Name = new JLabel("姓名:");

Name.setBounds(100,100,100,30);

Name.setFont(font);

FPanel.add(Name);

JTextField name = new JTextField();

name.setBounds(160,100,200,30);

FPanel.add(name);

JLabel ID = new JLabel("學(xué)號(hào):");

ID.setBounds(100,150,100,30);

ID.setFont(font);

FPanel.add(ID);

JTextField id = new JTextField();

id.setBounds(160,150,200,30);

id.setFont(font);

FPanel.add(id);

JLabel Score = new JLabel("成績(jī):");

Score.setBounds(100,200,100,30);

Score.setFont(font);

FPanel.add(Score);

JTextField score = new JTextField();

score.setBounds(160,200,200,30);

score.setFont(font);

FPanel.add(score);

JButton last = new JButton("取消");

last.setBounds(150,250,100,30);

last.setFont(font);

FPanel.add(last);

JButton com = new JButton("提交");

com.setBounds(260,250,100,30);

com.setFont(font);

FPanel.add(com);

last.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

FPanel.setVisible(false);

panel.setVisible(true);

}

});

com.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

String c = course.getText().trim();

String n = name.getText().trim();

String d = id.getText().trim();

String ss = score.getText().trim();

int s = 0;

for(int i=0;i

s=s*10+ss.charAt(i)-'0';

}

boolean idNum = jdbc.checkTable(c);

System.out.println(idNum+" really");

if(idNum&&s<=100&&s>=0&&n.length()!=0&&d.length()==9){

jdbc.saveMyTable(c,n,d,s);

panel.setVisible(true);

FPanel.setVisible(false);

}

else{

JFrame error = new JFrame("輸入錯(cuò)誤");

error.setBounds(200,200,400,230);

JPanel er = new JPanel();

er.setLayout(null);

error.add(er);

JLabel tip1 = new JLabel("tip1:課程號(hào)不能為空且首字母只能是字母或者下劃線!");

tip1.setBounds(10,0,350,30);

er.add(tip1);

JLabel tip2 = new JLabel("tip2:名字不能為空!");

tip2.setBounds(10,50,350,30);

er.add(tip2);

JLabel tip3 = new JLabel("tip3:學(xué)號(hào)必須是9位并且表格必須存在數(shù)據(jù)庫(kù)之中!");

tip3.setBounds(10,100,350,30);

er.add(tip3);

JButton reback = new JButton("返回");

reback.setBounds(170,150,60,20);

er.add(reback);

error.setVisible(true);

reback.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

error.setVisible(false);

}

});

}

}

});

}

});

query.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

JPanel which = new JPanel();

frame.add(which);

which.setLayout(null);

which.setVisible(true);

panel.setVisible(false);

JLabel tip1 = new JLabel("請(qǐng)輸入課程:");

tip1.setFont(font);

tip1.setBounds(100,100,100,30);

which.add(tip1);

JTextField answer1 = new JTextField();

answer1.setFont(font);

answer1.setBounds(200,100,300,30);

which.add(answer1);

JLabel tip2 = new JLabel("請(qǐng)輸入學(xué)號(hào):");

tip2.setFont(font);

tip2.setBounds(100,150,100,30);

which.add(tip2);

JTextField answer2 = new JTextField();

answer2.setFont(font);

answer2.setBounds(200,150,300,30);

which.add(answer2);

JButton reback = new JButton("返回");

reback.setFont(font);

reback.setBounds(270,200,100,20);

which.add(reback);

JButton submit = new JButton("提交");

submit.setFont(font);

submit.setBounds(400,200,100,20);

which.add(submit);

reback.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

which.setVisible(false);

panel.setVisible(true);

}

});

submit.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

String sc = answer1.getText().trim();

String idN = answer2.getText().trim();

String[] ans = new String[3];

ans[1]=ans[2]=ans[0]="查無(wú)此人!";

if(jdbc.checkTable(sc))jdbc.QueryStudent(sc,idN,ans);

else{

ans[0]=ans[1]=ans[2]="查無(wú)此表!";

}

JPanel show = new JPanel();

frame.add(show);

show.setLayout(null);

show.setVisible(true);

which.setVisible(false);

frame.add(show);

JLabel top = new JLabel("查詢成績(jī)");

top.setFont(font);

top.setBounds(250,20,100,30);

show.add(top);

JLabel name = new JLabel("姓名:");

name.setFont(font);

name.setBounds(100,60,100,30);

show.add(name);

JTextField Name = new JTextField(ans[0]);

Name.setFont(font);

Name.setBounds( 200,60,200,30);

show.add(Name);

JLabel id = new JLabel("學(xué)號(hào):");

id.setFont(font);

id.setBounds(100,120,100,30);

show.add(id);

JTextField ID = new JTextField(ans[1]);

ID.setFont(font);

ID.setBounds(200,120,200,30);

show.add(ID);

JLabel score = new JLabel("成績(jī):");

score.setFont(font);

score.setBounds(100,180,100,30);

show.add(score);

JTextField Score = new JTextField(ans[2]);

Score.setFont(font);

Score.setBounds(200,180,200,30);

show.add(Score);

JButton back = new JButton("返回");

back.setBounds(300,240,100,30);

back.setFont(font);

show.add(back);

back.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

which.setVisible(true);

show.setVisible(false);

}

});

}

});

}

});

watch.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

JPanel which = new JPanel();

frame.add(which);

which.setLayout(null);

which.setVisible(true);

panel.setVisible(false);

JLabel tip1 = new JLabel("請(qǐng)輸入課程:");

tip1.setFont(font);

tip1.setBounds(100,100,100,30);

which.add(tip1);

JTextField answer1 = new JTextField();

answer1.setFont(font);

answer1.setBounds(200,100,300,30);

which.add(answer1);

JButton reback = new JButton("返回");

reback.setFont(font);

reback.setBounds(270,150,100,20);

which.add(reback);

JButton submit = new JButton("提交");

submit.setFont(font);

submit.setBounds(400,150,100,20);

which.add(submit);

reback.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

which.setVisible(false);

panel.setVisible(true);

}

});

submit.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

String sc = answer1.getText().trim();

String[][] ans ;

if(!jdbc.checkTable(sc)){

ans = new String[1][3];

ans[0][0]=ans[0][1]=ans[0][2]="數(shù)據(jù)庫(kù)中無(wú)此表!";

}

else{

ans = jdbc.DisplayStudent(sc);

}

int[] now = {0};

JPanel show = new JPanel();

frame.add(show);

show.setLayout(null);

show.setVisible(true);

which.setVisible(false);

frame.add(show);

JLabel top = new JLabel("查詢成績(jī)");

top.setFont(font);

top.setBounds(250,20,100,30);

show.add(top);

JLabel name = new JLabel("姓名:");

name.setFont(font);

name.setBounds(100,60,100,30);

show.add(name);

JTextField Name = new JTextField();

Name.setFont(font);

Name.setBounds( 200,60,200,30);

show.add(Name);

Name.setText(ans[now[0]][0]);

JLabel id = new JLabel("學(xué)號(hào):");

id.setFont(font);

id.setBounds(100,120,100,30);

show.add(id);

JTextField ID = new JTextField();

ID.setFont(font);

ID.setBounds(200,120,200,30);

show.add(ID);

ID.setText(ans[now[0]][1]);

JLabel score = new JLabel("成績(jī):");

score.setFont(font);

score.setBounds(100,180,100,30);

show.add(score);

JTextField Score = new JTextField();

Score.setFont(font);

Score.setBounds(200,180,200,30);

show.add(Score);

Score.setText(ans[now[0]][2]);

JButton back = new JButton("下一頁(yè)");

back.setBounds(300,240,100,30);

back.setFont(font);

show.add(back);

back.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent actionEvent) {

now[0]++;

if(now[0] < ans.length) {

Name.setText(ans[now[0]][0]);

ID.setText(ans[now[0]][1]);

Score.setText(ans[now[0]][2]);

}

else{

show.setVisible(false);

which.setVisible(true);

}

}

});

}

});

}

});

}

}

其實(shí)我覺(jué)得做了很多重復(fù)的東西,還有很多值得改善的地方。

注意這個(gè)運(yùn)行要導(dǎo)入mysql和Java的連接包。

總結(jié)

以上是生活随笔為你收集整理的分数统计设计java程序_(windows综合程序)设计一个学生平时成绩统计软件 最后的Java作业...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。