TextField a1,a2; Box b1,b2,b3,b4,b5; ss s;
zhuchuangkou(){ button1=new Button(\登陆\ button2=new Button(\删除\ button3=new Button(\修改\ button4=new Button(\添加\ tuichu=new Button(\退出\ p1=new Panel(); p2=new Panel(); p3=new Panel(); l1=new Label(\学生成绩管理\ l1.setFont(new Font(\宋体\ l1.setBackground(Color.green); l2=new Label(\登录名\ l3=new Label(\密码\ a1=new TextField(10); a2=new TextField(10); a2.setEchoChar('*'); b1=Box.createVerticalBox(); b1.add(l2); b1.add(Box.createVerticalStrut(8)); b1.add(l3); b2=Box.createVerticalBox(); b2.add(a1); b2.add(Box.createVerticalStrut(8)); b2.add(a2); b4=Box.createHorizontalBox(); b4.add(button1); b4.add(Box.createHorizontalStrut(10)); b4.add(tuichu); b3=Box.createHorizontalBox(); b3.add(b1); b3.add(Box.createHorizontalStrut(10)); b3.add(b2); b5=Box.createVerticalBox(); b5.add(b3);
}
b5.add(Box.createVerticalStrut(8)); b5.add(b4); button1.addActionListener(this); button2.addActionListener(this); button3.addActionListener(this); button4.addActionListener(this); tuichu.addActionListener(this); p1.add(l1); p2.add(b5); add(p1,BorderLayout.NORTH); add(p2,BorderLayout.CENTER); add(p3,BorderLayout.PAGE_END); addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ dispose(); } }); setBackground(Color.RED); setBounds(10, 10, 1000, 500); setVisible(true); validate(); }
public void actionPerformed(ActionEvent e){ if(e.getSource()==tuichu){ System.exit(0); } if(e.getSource()==button1){ if(a1.getText().equals(\ new chuankou(); System.out.println(\ dispose(); } else{ System.out.print(\ } } }
第四部分查询界面实现: import java.awt.*; import java.awt.event.*; import java.sql.*;
import javax.swing.JOptionPane;
public class ss extends Frame implements TextListener,ActionListener{
Button xunzhao; TextField input; TextArea show; String s; int k;
Connection con;
Statement sql; int sum=0; ResultSet rs;
ss(){
Panel p=new Panel(); xunzhao= new Button(\查找\input= new TextField(10); show= new TextArea(6,43); p.add(new Label(\输入学号\p.add(input); p.add(xunzhao);
xunzhao.addActionListener(this); show.addTextListener(this); show.setEditable(false); add(p,BorderLayout.NORTH); add(show,BorderLayout.CENTER);
setBounds(10,30,500,200);
}
setVisible(true); validate();
addWindowListener(new WindowAdapter(){ });
public void windowClosing(WindowEvent e){ }
dispose();
public void actionPerformed(ActionEvent ee) {
boolean boo=true; s=input.getText(); k=Integer.parseInt(s);
try { Class.forName(\
catch(ClassNotFoundException eee) { System.out.println(\;}
try { con=DriverManager.getConnection(\ sql=con.createStatement();
rs=sql.executeQuery(\ while(rs.next()) {
int number=rs.getInt(\
String name=rs.getString(\ String date=rs.getString(\ int math=rs.getInt(\
int english=rs.getInt(\ if(number==k) { boo=false;
show.setText(null);
show.append(\学号:\ 姓名:\ 出生:\数学 \英语 \
}
show.append(\
} con.close(); if(boo){ } }
catch(SQLException eee) { System.out.println(eee); } }
第五部分删除:
import java.awt.*;
import java.awt.event.*; import java.sql.*;
import javax.swing.JOptionPane;
public class shanchu extends Frame implements TextListener,ActionListener{ Button xunzhao; TextField input; TextArea show; String s; int k,s1,j; Connection con; Statement sql; int sum=0; ResultSet rs; shanchu(){ Panel p=new Panel(); xunzhao= new Button(\删除\ input= new TextField(10); show= new TextArea(6,43); p.add(new Label(\输入要删除的\学号\ p.add(input); p.add(xunzhao); xunzhao.addActionListener(this); show.addTextListener(this); show.setEditable(false);
JOptionPane.showMessageDialog(this, \你输入的学号不存在\
}