仅仅给你个参考//JavaGroupProject_StudentManagement源码//NetBeansIDE6.5环境packagestudentmanager;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjava.io.*;importjava.util.*;classStudentimplementsjava.io.Serializable{Stringnumber,name,specialty,grade,borth,sex;publicStudent(){};publicvoidsetNumber(Stringnumber){this.number=number;}publicStringgetNumber(){returnnumber;}publicvoidsetName(Stringname){this.name=name;}publicStringgetName(){returnname;}publicvoidsetSex(Stringsex){this.sex=sex;}publicStringgetSex(){returnsex;}publicvoidsetSpecialty(Stringspecialty){this.specialty=specialty;}publicStringgetSpecialty(){returnspecialty;}publicvoidsetGrade(Stringgrade){this.grade=grade;}publicStringgetGrade(){returngrade;}publicvoidsetBorth(Stringborth){this.borth=borth;}publicStringgetBorth(){returnborth;}}publicclassStudentManagerextendsJFrame{JLabellb=newJLabel("录入请先输入记录,查询、删除请先输入学号,修改是对查询"+"内容改后的保存!");JTextField学号,姓名,专业,年级,出生;JRadioButton男,女;ButtonGroupgroup=null;JButton录入,查询,删除,修改,显示;JPanelp1,p2,p3,p4,p5,p6,pv,ph;Student学生=null;Hashtable学生散列表=null;Filefile=null;FileInputStreaminOne=null;ObjectInputStreaminTwo=null;FileOutputStreamoutOne=null;ObjectOutputStreamoutTwo=null;publicStudentManager(){super("学生基本信息管理系统");学号=newJTextField(10);姓名=newJTextField(10);专业=newJTextField(10);年级=newJTextField(10);出生=newJTextField(10);group=newButtonGroup();男=newJRadioButton("男",true);女=newJRadioButton("女",false);group.add(男);group.add(女);录入=newJButton("录入");查询=newJButton("查询");删除=newJButton("删除");修改=newJButton("修改");显示=newJButton("显示");录入.addActionListener(newInputAct());查询.addActionListener(newInquestAct());修改.addActionListener(newModifyAct());删除.addActionListener(newDeleteAct());显示.addActionListener(newShowAct());修改.setEnabled(false);p1=newJPanel();p1.add(newJLabel("学号:",JLabel.CENTER));p1.add(学号);p2=newJPanel();p2.add(newJLabel("姓名:",JLabel.CENTER));p2.add(姓名);p3=newJPanel();p3.add(newJLabel("性别:",JLabel.CENTER));p3.add(男);p3.add(女);p4=newJPanel();p4.add(newJLabel("专业:",JLabel.CENTER));p4.add(专业);p5=newJPanel();p5.add(newJLabel("年级:",JLabel.CENTER));p5.add(年级);p6=newJPanel();p6.add(newJLabel("出生:",JLabel.CENTER));p6.add(出生);pv=newJPanel();pv.setLayout(newGridLayout(6,1));pv.add(p1);pv.add(p2);pv.add(p3);pv.add(p4);pv.add(p5);pv.add(p6);ph=newJPanel();ph.add(录入);ph.add(查询);ph.add(修改);ph.add(删除);ph.add(显示);file=newFile("学生信息.txt");学生散列表=newHashtable();if(!file.exists()){try{FileOutputStreamout=newFileOutputStream(file);ObjectOutputStreamobjectOut=newObjectOutputStream(out);objectOut.writeObject(学生散列表);objectOut.close();out.close();}catch(IOExceptione){}}Containercon=getContentPane();con.setLayout(newBorderLayout());con.add(lb,BorderLayout.NORTH);con.add(pv,BorderLayout.CENTER);con.add(ph,BorderLayout.SOUTH);setDefaultCloseOperation(EXIT_ON_CLOSE);setBounds(100,100,600,300);setVisible(true);}publicstaticvoidmain(String[]args){newStudentManager();}classInputActimplementsActionListener{publicvoidactionPerformed(ActionEvente){修改.setEnabled(false);Stringnumber="";number=学号.getText();if(number.length()>0){try{inOne=newFileInputStream(file);inTwo=newObjectInputStream(inOne);学生散列表=(Hashtable)inTwo.readObject();inOne.close();inTwo.close();}catch(Exceptionee){System.out.println("创建散列表出现问题!");}if(学生散列表.containsKey(number)){Stringwarning="该生信息已存在,请到修改页面修改!";JOptionPane.showMessageDialog(null,warning,"警告",JOptionPane.WARNING_MESSAGE);}//endif1else{Stringm="该生信息将被录入!";intok=JOptionPane.showConfirmDialog(null,m,"确认",JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE);if(ok==JOptionPane.YES_OPTION){Stringname=姓名.getText();Stringspecialty=专业.getText();Stringgrade=年级.getText();Stringborth=出生.getText();Stringsex=null;if(男.isSelected()){sex=男.getText();}else{sex=女.getText();}学生=newStudent();学生.setNumber(number);学生.setName(name);学生.setSpecialty(specialty);学生.setGrade(grade);学生.setBorth(borth);学生.setSex(sex);try{outOne=newFileOutputStream(file);outTwo=newObjectOutputStream(outOne);学生散列表.put(number,学生);outTwo.writeObject(学生散列表);outTwo.close();outOne.close();}catch(Exceptionee){System.out.println("输出散列表出现问题!");}学号.setText(null);姓名.setText(null);专业.setText(null);年级.setText(null);出生.setText(null);}}//endelse1}//endif0else{Stringwarning="必须输入学号!";JOptionPane.showMessageDialog(null,warning,"警告",JOptionPane.WARNING_MESSAGE);}//endelse0}//endactionPerformed}//endclassclassInquestActimplementsActionListener{publicvoidactionPerformed(ActionEvente){Stringnumber="";number=学号.getText();if(number.length()>0){try{inOne=newFileInputStream(file);inTwo=newObjectInputStream(inOne);学生散列表=(Hashtable)inTwo.readObject();inOne.close();inTwo.close();}catch(Exceptionee){System.out.println("散列表有问题!");}if(学生散列表.containsKey(number)){修改.setEnabled(true);Studentstu=(Student)学生散列表.get(number);姓名.setText(stu.getName());专业.setText(stu.getSpecialty());年级.setText(stu.getGrade());出生.setText(stu.getBorth());if(stu.getSex().equals("男")){男.setSelected(true);}else{女.setSelected(true);}}else{修改.setEnabled(false);Stringwarning="该学号不存在!";JOptionPane.showMessageDialog(null,warning,"警告",JOptionPane.WARNING_MESSAGE);}}else{修改.setEnabled(false);Stringwarning="必须输入学号!";JOptionPane.showMessageDialog(null,warning,"警告",JOptionPane.WARNING_MESSAGE);}}}classModifyActimplementsActionListener{publicvoidactionPerformed(ActionEvente){Stringnumber=学号.getText();Stringname=姓名.getText();Stringspecialty=专业.getText();Stringgrade=年级.getText();Stringborth=出生.getText();Stringsex=null;if(男.isSelected()){sex=男.getText();}else{sex=女.getText();}Student学生=newStudent();学生.setNumber(number);学生.setName(name);学生.setSpecialty(specialty);学生.setGrade(grade);学生.setBorth(borth);学生.setSex(sex);try{outOne=newFileOutputStream(file);outTwo=newObjectOutputStream(outOne);学生散列表.put(number,学生);outTwo.writeObject(学生散列表);outTwo.close();outOne.close();学号.setText(null);姓名.setText(null);专业.setText(null);年级.setText(null);出生.setText(null);}catch(Exceptionee){System.out.println("录入修改出现异常!");修改.setEnabled(false);}}}classDeleteActimplementsActionListener{publicvoidactionPerformed(ActionEvente){修改.setEnabled(false);Stringnumber=学号.getText();if(number.length()>0){try{inOne=newFileInputStream(file);inTwo=newObjectInputStream(inOne);学生散列表=(Hashtable)inTwo.readObject();inOne.close();inTwo.close();}catch(Exceptionee){}if(学生散列表.containsKey(number)){Studentstu=(Student)学生散列表.get(number);姓名.setText(stu.getName());专业.setText(stu.getSpecialty());年级.setText(stu.getGrade());出生.setText(stu.getBorth());if(stu.getSex().equals("男")){男.setSelected(true);}else{女.setSelected(true);}}Stringm="确定要删除该学生的记录吗?";intok=JOptionPane.showConfirmDialog(null,m,"确认",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);if(ok==JOptionPane.YES_OPTION){学生散列表.remove(number);try{outOne=newFileOutputStream(file);outTwo=newObjectOutputStream(outOne);outTwo.writeObject(学生散列表);outTwo.close();outOne.close();学号.setText(null);姓名.setText(null);专业.setText(null);年级.setText(null);出生.setText(null);}catch(Exceptionee){System.out.println(ee);}}elseif(ok==JOptionPane.NO_OPTION){学号.setText(null);姓名.setText(null);专业.setText(null);年级.setText(null);出生.setText(null);}else{Stringwarning="该学号不存在!";JOptionPane.showMessageDialog(null,warning,"警告",JOptionPane.WARNING_MESSAGE);}}else{Stringwarning="必须输入学号!";JOptionPane.showMessageDialog(null,warning,"警告",JOptionPane.WARNING_MESSAGE);}}}classShowActimplementsActionListener{publicvoidactionPerformed(ActionEvente){newStudentShow(file);}}classStudentShowextendsJDialog{Hashtable学生散列表=null;JTextArea显示=null;FileInputStreaminOne=null;ObjectInputStreaminTwo=null;Filefile=null;publicStudentShow(Filefile){super(newJFrame(),"显示对话框");this.file=file;显示=newJTextArea(16,30);try{inOne=newFileInputStream(file);inTwo=newObjectInputStream(inOne);学生散列表=(Hashtable)inTwo.readObject();inOne.close();inTwo.close();}catch(Exceptionee){}if(学生散列表.isEmpty())显示.append("目前还没有学生的信息记录!\n");else{显示.setText("学号姓名性别专业年级出生\n");for(Enumerationenm=学生散列表.elements();enm.hasMoreElements();){Studentstu=(Student)enm.nextElement();Stringsex="";if(stu.getSex().equals("男"))sex="男";elsesex="女";Stringstr=stu.getNumber()+","+stu.getName()+","+sex+","+stu.getSpecialty()+","+stu.getGrade()+","+stu.getBorth()+"\n";显示.append(str);}}JScrollPanescroll=newJScrollPane(显示);Containercon=getContentPane();con.add("Center",scroll);con.validate();setVisible(true);setBounds(200,200,400,300);addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){setVisible(false);}});}}}