java学生成绩管理系统课程设计报告以及代码共享Word格式文档下载.docx
《java学生成绩管理系统课程设计报告以及代码共享Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《java学生成绩管理系统课程设计报告以及代码共享Word格式文档下载.docx(19页珍藏版)》请在冰豆网上搜索。
用户输入数据后,整理数据,通过JDBC连接数据库进行各种操作。
5、界面设计
三、测试分析
1.测试的预计结果
1、添加一项学生数据,学号1234,姓名xyf,班级计科8,英语成绩90,数学90,计算机75。
2、修改英语成绩88。
3、删除该记录
2.本程序的测试情况,与预计结果作对比
1、添加
2、修改
3、删除
说明:
限于技术问题,本程序有比较多BUG,而且只造了部分功能,但是基本上可以实现文本的编辑。
附录:
源代码
importjava.awt.*;
importjava.text.*;
importjavax.swing.*;
importjava.sql.*;
importjava.io.*;
publicclassasan1extendsWindowAdapterimplementsActionListener
{
JFrameframe;
//进入系统界面
JFrameframe1;
//主界面
JFrameFrame_Add;
//添加学生的窗口
JFrameFrame_Del;
//删除学生的窗口
JFrameFrame_Updata;
//修改学生的窗口
JFrameFrame_Show;
//查看学生的窗口
JTextFieldnum=newJTextField(20);
//学号
JTextFieldname=newJTextField(20);
//姓名
JTextFieldgreat=newJTextField(20);
//计算机
JTextFieldenglish=newJTextField(20);
//英语
JTextFieldmath=newJTextField(20);
//数学
JTextFieldcomputer=newJTextField(20);
JComboBoxpl;
publicasan1()
{
stu_in();
}
publicvoidsetfont(JButtonbutton)//设置按钮的大小及字体
button.setFont(newFont("
华文彩云"
Font.PLAIN,18));
publicvoidstu_in()
frame=newJFrame("
学生成绩管理系统"
);
frame.setBounds(150,200,600,300);
//窗口大小及开始在屏幕上的位置。
Containercp=frame.getContentPane();
cp.setLayout(newBorderLayout());
BackImagep=newBackImage();
p.setLayout(newGridBagLayout());
GridBagConstraintsc=newGridBagConstraints();
cp.add(p,BorderLayout.CENTER);
JLabellabel=newJLabel("
xx大学计算机学院08级8班xx"
label.setFont(newFont("
Font.PLAIN,30));
JButtonbut_in=newJButton("
进入系统"
JButtonbut_out=newJButton("
退出系统"
but_in.setFont(newFont("
but_out.setFont(newFont("
but_in.addActionListener(this);
but_out.addActionListener(this);
p.add(but_in,c);
p.add(but_out,c);
frame.add(label,BorderLayout.PAGE_START);
frame.setResizable(false);
//窗口不随鼠标拖动而改变大小
frame.addWindowFocusListener(this);
//添加窗口的监控类
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
publicvoidstu_add()
Frame_Add=newJFrame("
添加学生成绩"
Frame_Add.setResizable(false);
ContainerconterPane;
JPanelp=newJPanel();
JLabelJ1=newJLabel("
学号:
"
JLabelJ2=newJLabel("
姓名:
JLabelJ6=newJLabel("
班级:
JLabelJ3=newJLabel("
英语:
JLabelJ4=newJLabel("
数学:
JLabelJ5=newJLabel("
计算机:
JButtonadd=newJButton("
添加"
add.addActionListener(this);
//添加
JButtonclear=newJButton("
清空"
//清除
clear.addActionListener(this);
JButtonexit=newJButton("
退出"
//退出
exit.addActionListener(this);
GridBagLayoutgridBag=newGridBagLayout();
GridBagConstraintsgridBagCon;
num=newJTextField(20);
name=newJTextField(20);
great=newJTextField(20);
english=newJTextField(20);
math=newJTextField(20);
computer=newJTextField(20);
p.add(J1);
J1.setLabelFor(num);
p.add(num);
p.add(J2);
J2.setLabelFor(name);
p.add(name);
p.add(J6);
J6.setLabelFor(great);
p.add(great);
p.add(J3);
J3.setLabelFor(english);
p.add(english);
p.add(J4);
J4.setLabelFor(math);
p.add(math);
p.add(J5);
J5.setLabelFor(computer);
p.add(computer);
p.add(add);
p.add(clear);
p.add(exit);
Frame_Add.setBounds(300,280,300,230);
Frame_Add.add(p);
Frame_Add.show();
publicvoidstu_del()
Frame_Del=newJFrame("
删除学生成绩"
Frame_Del.setResizable(false);
StringXueHao="
;
Data_accessDB=newData_access();
Vectorrec_vector=newVector();
//列名集合
intnumberOfColumns;
try
{
Stringquery="
SELECTIDFROMstudent"
{
rec_vector.addElement(XueHao);
}
}catch(Exceptionex)
JOptionPane.showMessageDialog(null,"
连接数据库失败"
"
数据连接"
JOptionPane.ERROR_MESSAGE);
};
pl=newJComboBox(rec_vector);
pl.setEditable(true);
pl.setPreferredSize(newDimension(135,22));
//框的长和高
pl.addActionListener(this);
JButtonupdata=newJButton("
删除"
updata.addActionListener(this);
JButtonexit1=newJButton("
OUT"
exit1.addActionListener(this);
p.add(pl);
p.add(updata);
p.add(exit1);
Frame_Del.setBounds(300,280,210,100);
Frame_Del.add(p);
Frame_Del.show();
publicvoidstu_updata()
Frame_Updata=newJFrame("
修改学生成绩"
Frame_Updata.setResizable(false);
修改"
JButtonclear1=newJButton("
clear1.addActionListener(this);
name=newJTextField(12);
great=newJTextField(12);
english=newJTextField(12);
math=newJTextField(12);
computer=newJTextField(12);
p.add(clear1);
Frame_Updata.setBounds(300,280,210,230);
Frame_Updata.add(p);
Frame_Updata.show();
publicvoidstu_show()
Frame_Show=newJFrame("
查看学生成绩"
Frame_Show.setResizable(false);
Data_accessDB=newData_access();
StringXueHao="
try
name.setEditable(false);
great.setEditable(false);
english.setEditable(false);
math.setEditable(false);
computer.setEditable(false);
JButtonshow=newJButton("
查看"
show.addActionListener(this);
p.add(show);
Frame_Show.setBounds(300,280,210,230);
Frame_Show.add(p);
Frame_Show.show();
publicintmian_JFrame()throwsException
JPanelpane=newJPanel();
frame1=newJFrame("
JTablefriends=newJTable();
DefaultTableModeldt=newDefaultTableModel();
friends.setModel(dt);
VectorvecColumnName=newVector();
intnumberOfColumns;
intb=1;
Stu_ChangeSadd=newStu_Change();
{
Sadd.stuSum();
//以下是显示数据库中的列名的代码
dt.addColumn("
学号"
姓名"
班级"
英语"
数学"
计算机"
总分"
//以下是在表格中显示数据中的内容
{
VectornewRow=newVector();
intc=1;
while(c<
=numberOfColumns)
c++;
dt.addRow(newRow);
}
}catch(Exceptionex)
return0;
friends.setPreferredScrollableViewportSize(newDimension(580,200));
//设置表格的大小
friends.setRowHeight(25);
//设置每行的高度为20
friends.setRowHeight(0,25);
//设置第1行的高度为20
friends.setRowMargin
(2);
//设置相邻两行单元格的距离5
friends.setRowSelectionAllowed(true);
//设置可否被选择.默认为false
friends.setSelectionBackground(Color.white);
//设置所选择行的背景色
friends.setSelectionForeground(Color.red);
//设置所选择行的前景色
friends.setGridColor(Color.black);
//设置网格线的颜色
friends.clearSelection();
//取消选择
friends.setDragEnabled(false);
//不懂这个
friends.setShowGrid(false);
//是否显示网格线
friends.setShowHorizontalLines(false);
//是否显示水平的网格线
friends.setShowVerticalLines(true);
//是否显示垂直的网格线
//friends.setEditable(false);
friends.doLayout();
friends.setBackgr