Java学生课程设计源码Word格式.docx
《Java学生课程设计源码Word格式.docx》由会员分享,可在线阅读,更多相关《Java学生课程设计源码Word格式.docx(25页珍藏版)》请在冰豆网上搜索。
b3=newJButton("
退出"
p1.add(newLabel("
"
));
p2.add(newLabel("
用户名"
p2.add(f1);
p3.add(newLabel("
密码"
p3.add(f2);
p4.add(b1);
p4.add(b2);
p4.add(b3);
cp.add(p1);
cp.add(p2);
cp.add(p3);
cp.add(p4);
b1.addActionListener(newEnter());
b2.addActionListener(newReWrite());
b3.addActionListener(newClose());
}
classEnterimplementsActionListener{
publicvoidactionPerformed(ActionEvente)
{
if((f1.getText()).equals("
任艳云"
)&
&
(f2.getText()).equals("
ren12"
))
{
XueShengframe1=newXueSheng();
frame1.setBounds(200,200,400,400);
frame1.setVisible(true);
}
elseJOptionPane.showMessageDialog(null,"
用户名或密码错误,请重新登录!
"
}
classReWriteimplementsActionListener{
{
f1.setText("
f2.setText("
f1.requestFocus();
classCloseimplementsActionListener{
JButtonbt=(JButton)e.getSource();
if(bt==b3){
System.exit(0);
//主函数程序开始
publicstaticvoidmain(String[]args){
Loginlog=newLogin();
log.setTitle("
系统登录"
log.setBounds(200,200,300,300);
log.setBackground(Color.red);
log.setVisible(true);
//信息管理界面内部类进行初始化和保存
classXueShengextendsJFrameimplementsActionListener{
privateJButtoncx,zj,tc,sc,xg,tj;
publicXueSheng()
Containerc=this.getContentPane();
c.setLayout(newGridLayout(4,1));
c.setBackground(Color.cyan);
c.setFont(newFont("
true"
Font.TRUETYPE_FONT,13));
JPanelpanel1=newJPanel();
panel1.setBackground(Color.cyan);
JLabellabel1=newJLabel("
欢迎登入成绩管理主页"
SwingConstants.CENTER);
label1.setFont(newFont("
Font.TRUETYPE_FONT,15));
panel1.add(label1);
JPanelpanel2=newJPanel();
panel2.setBackground(Color.cyan);
JPanelpanel3=newJPanel();
panel3.setBackground(Color.cyan);
JPanelpanel4=newJPanel();
panel4.setBackground(Color.cyan);
//添加按钮
cx=newJButton("
查询"
panel2.add(cx);
zj=newJButton("
增加"
panel2.add(zj);
sc=newJButton("
删除"
panel3.add(sc);
xg=newJButton("
修改"
panel3.add(xg);
tc=newJButton("
panel4.add(tc);
c.add(panel1);
c.add(panel2);
c.add(panel3);
c.add(panel4);
cx.addActionListener(this);
zj.addActionListener(this);
sc.addActionListener(this);
xg.addActionListener(this);
tc.addActionListener(this);
this.setVisible(true);
publicvoidactionPerformed(ActionEvente)
if(e.getSource()==cx){
Queryf=newQuery();
if(e.getSource()==zj){
Inseterf=newInseter();
if(e.getSource()==sc){
Deleted=newDelete();
if(e.getSource()==xg){
Updatex=newUpdate();
if(e.getSource()==tc){
shutDown();
privatevoidshutDown()
JOptionPane.showMessageDialog(null,"
信息已保存"
this.dispose();
}
插入源码:
importjava.awt.Color;
importjava.awt.Container;
importjava.awt.FlowLayout;
importjava.awt.Font;
importjava.awt.GridLayout;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.io.FileNotFoundException;
importjava.io.IOException;
importjavax.swing.JButton;
importjavax.swing.JFrame;
importjavax.swing.JLabel;
importjavax.swing.JOptionPane;
importjavax.swing.JPanel;
importjavax.swing.JTextField;
importjavax.swing.SwingConstants;
importcom.lb.bean.Student;
importcom.lb.dao.DaoImpl;
classInseterextendsJFrameimplementsActionListener{
privateJTextFieldSTNOText,SNAMEText,MAText,CHIText,JAVAText;
privateJButtonb1,b2,b3;
privateStringSTNO,SNAME,MAT,CHI,JAVA;
privateStudenta;
publicInseter(){
super("
添加学生信息"
Containerc2=this.getContentPane();
c2.setLayout(newGridLayout(3,1));
c2.setBackground(Color.cyan);
JPanelcenter=newJPanel();
center.setLayout(newGridLayout(5,4));
center.setBackground(Color.cyan);
JPanellow=newJPanel(newFlowLayout());
low.setBackground(Color.cyan);
JLabellabel1=newJLabel("
SwingConstants.CENTER);
label1.setFont(newFont("
TRUE"
Font.TRUETYPE_FONT,20));
c2.add(label1);
STNOText=newJTextField(20);
//30列文本框
SNAMEText=newJTextField(20);
CHIText=newJTextField(20);
MAText=newJTextField(20);
JAVAText=newJTextField(20);
center.add(newJLabel("
学号:
SwingConstants.CENTER));
//添加标签学号写在标签中间
center.add(STNOText);
//添加文本框
姓名:
center.add(SNAMEText);
语文:
center.add(CHIText);
数学:
center.add(MAText);
java:
center.add(JAVAText);
c2.add(center);
b1=newJButton("
添加"
b2=newJButton("
清除"
b3=newJButton("
low.add(b1);
low.add(b2);
low.add(b3);
c2.add(low);
//添加监听
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
this.setBounds(200,200,600,400);
this.setVisible(true);
this.setTitle("
publicvoidactionPerformed(ActionEvente){
if(e.getSource()==b1){
try{
inseter();
}catch(FileNotFoundExceptione1){
e1.printStackTrace();
}catch(IOExceptione1){
if(e.getSource()==b2){
clearForm();
if(e.getSource()==b3){
privatevoidinseter()throwsFileNotFoundException,IOException{
STNO=STNOText.getText();
SNAME=SNAMEText.getText();
CHI=CHIText.getText();
MAT=MAText.getText();
JAVA=JAVAText.getText();
Studentstu=newStudent();
if(STNO.length()==0||SNAME.length()==0||MAT.length()==0
||JAVA.length()==0||CHI.length()==0){
JOptionPane.showMessageDialog(this,"
请添加完全信息"
else{
Studenta=newStudent(SNAME,STNO,
Integer.parseInt(CHI),Integer.parseInt(MAT),Integer.parseInt(JAVA));
DaoImpldi=newDaoImpl();
di.inseter(a);
JOptionPane.showMessageDialog(this,"
添加成功!
!
privatevoidclearForm(){
STNOText.setText("
SNAMEText.setText("
MAText.setText("
CHIText.setText("
JAVAText.setText("
删除源码:
importjavax.swing.JScrollPane;
importjavax.swing.JTextArea;
classDeleteextendsJFrameimplementsActionListener{
privateJButtonyes;
privateJButtoncancle;
privateJTextFieldtext1;
privateStringSTNO;
publicDelete(){
Containerc3=this.getContentPane();
c3.setBackground(Color.pink);
c3.setLayout(newGridLayout(3,1));
c3.setFont(newFont("
JPanelp1=newJPanel();
p1.setBackground(Color.pink);
JPanelp2=newJPanel();
p2.setBackground(Color.pink);
删除学生信息"
label1.setForeground(Color.blue);
c3.add(label1);
JLabellabel2=newJLabel("
请输入学号"
text1=newJTextField(10);
p1.add(label2);
p1.add(text1);
c3.add(p1);
yes=newJButton("
确定"
cancle=newJButton("
p2.add(yes);
p2.add(cancle);
c3.add(p2);
yes.addActionListener(this);
cancle.addActionListener(this);
this.setBounds(200,200,400,300);
publicvoidactionPerformed(ActionEvente){
if(e.getSource()==yes){
DaoImpldi=newDaoImpl();
STNO=text1.getText();
di.delete(STNO);
if(e.getSource()==cancle){
this.dispose();
删除成功!
修改源码:
classUpdateextendsJFrameimplementsActionListener{
privateJButtonb1,b2,b3;
publicUpdate(){
Containerc4=this.getContentPane();
c4.setLayout(newGridLayout(5,1));
c4.setFont(newFont(