用java输出学生信息表代码-学生信息管理系统JAVASE版-1.1.1901_第1页
用java输出学生信息表代码-学生信息管理系统JAVASE版-1.1.1901_第2页
用java输出学生信息表代码-学生信息管理系统JAVASE版-1.1.1901_第3页
用java输出学生信息表代码-学生信息管理系统JAVASE版-1.1.1901_第4页
用java输出学生信息表代码-学生信息管理系统JAVASE版-1.1.1901_第5页
已阅读5页,还剩27页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

⽤java输出学⽣信息表代码_学⽣信息管理系统JAVASE版--1.1.1现在终于可以写出实⽤⼀点的程序了。虽然这个程序的功能⾮常之简陋,⽽且还有BUG。不过最起码已经可以使⽤了。功能预览和下⼀步的⽬标程序主界⾯查询功能:⽬前只做了⼀个表的增、删、改、查。下⼀步应该就是把功能完善,⽐如加⼊错误处理,⽐如加⼊成绩部分。完成⼀个班级内的学⽣信息管理的功能,应该具有学⽣的基本信息查询,成绩管理这两个功能不过有⼀个问题就是,在表格更新这⼀部分,每更新⼀次,就要创建⼀个tabliModel对象,感觉可以改进。再有就是MVC模式,其实也就接触设计模式。还有就是整成那种可执⾏⽂件。程序代码mysql建表语句CREATETABLEstudent(stuIdINTPRIMARYKEY,stuNameVARCHAR(20)NOTNULLDEFAULT'',stuAgeINTNOTNULLDEFAULT0,stuSexVARCHAR(5)NOTNULLDEFAULT'')enginemyisamcharsetutf8;JAVA代码:数据库部分com.laolang.domain(数据对象,这⾥只有⼀个Student对象)packagecom.laolang.domain;/***学⽣对象,对应数据库中student表*/publicclassStudent{/***Instantiatesanewstudent.*/publicStudent(){super();}/***Instantiatesanewstudent.**@paramstuId*thestuid*@paramstuName*thestuname*@paramstuAge*thestuage*@paramstuSex*thestusex*/publicStudent(intstuId,StringstuName,intstuAge,StringstuSex){super();this.stuId=stuId;this.stuName=stuName;this.stuAge=stuAge;this.stuSex=stuSex;}/**(non-Javadoc)*

*@seejava.lang.Object#toString()*/@OverridepublicStringtoString(){return"Student[stuId="+stuId+",stuName="+stuName+",stuAge="+stuAge+",stuSex="+stuSex+"]";}/***Getsthestuid.**@returnthestuid*/publicintgetStuId(){returnstuId;}/***Setsthestuid.**@paramstuId*thenewstuid*/publicvoidsetStuId(intstuId){this.stuId=stuId;}/***Getsthestuname.**@returnthestuname*/publicStringgetStuName(){returnstuName;}/***Setsthestuname.

**@paramstuName*thenewstuname*/publicvoidsetStuName(StringstuName){this.stuName=stuName;}/***Getsthestuage.**@returnthestuage*/publicintgetStuAge(){returnstuAge;}/***Setsthestuage.**@paramstuAge*thenewstuage*/publicvoidsetStuAge(intstuAge){this.stuAge=stuAge;}/***Getsthestusex.**@returnthestusex*/publicStringgetStuSex(){returnstuSex;}/***Setsthestusex.

**@paramstuSex*thenewstusex*/publicvoidsetStuSex(StringstuSex){this.stuSex=stuSex;}/**学⽣编号*/privateintstuId;/**学⽣姓名*/privateStringstuName;/**学⽣年龄*/privateintstuAge;/**学⽣性别*/privateStringstuSex;}com.laolang.db(数据库连接⼯具类,⽤的是属性⽂件的⽅式)laolangDB(⼯具类)packagecom.laolang.db;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;importjava.util.ResourceBundle;/***数据库连接和关闭⼯具类*/publicclasslaolangDB{/**数据库连接地址*/privatestaticStringURL;/**数据库⽤户名*/privatestaticStringUSERNAME;/**数据库密码*/

privatestaticStringUSERPASSWORD;/**mysql驱动*/privatestaticStringDRIVER;/**Therb.*/privatestaticResourceBundlerb=ResourceBundle.getBundle("com.laolang.db.db-config");/***使⽤静态代码块加载驱动*/static{URL=rb.getString("jdbc.url");USERNAME=rb.getString("jdbc.username");USERPASSWORD=rb.getString("jdbc.userpassword");DRIVER=rb.getString("jdbc.driver");try{Class.forName(DRIVER);}catch(ClassNotFoundExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}}/***获得链接.**@returntheconnection*/publicstaticConnectiongetConnection(){Connectionconn=null;try{conn=DriverManager.getConnection(URL,USERNAME,USERPASSWORD);}catch(SQLExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}

returnconn;}/***关闭链接.**@paramrsthers*@parampstheps*@paramconntheconn*/publicstaticvoidcloseConnection(ResultSetrs,Statementps,Connectionconn){try{if(null!=rs)rs.close();if(null!=ps)ps.close();if(null!=conn)conn.close();}catch(SQLExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}}}perties(数据⽂件):jdbc.url=jdbc:mysql://localhost:3306/studentmanager1.1.1jdbc.username=rootjdbc.userpassword=123456jdbc.driver=com.mysql.jdbc.Drivercom.laolang.dao(数据库操作接⼝)StudentDaopackagecom.laolang.dao;importjava.sql.SQLException;importjava.util.List;

importcom.laolang.domain.Student;/***数据库操作接⼝*/publicinterfaceStudentDao{/***插⼊学⽣基本信息.**@paramstu*学⽣对象*@throwsSQLException*theSQLexception*/publicvoidinsertStudent(Studentstu)throwsSQLException;/***删除学⽣基本信息.**@paramstuId*学⽣编号*@throwsSQLException*theSQLexception*/publicvoiddeleteStudent(intstuId)throwsSQLException;/***更新学⽣基本信息.**@paramstu*学⽣对象*@throwsSQLException*theSQLexception*/publicvoidupdateStudent(Studentstu)throwsSQLException;/***S通过编号查询学⽣基本信息.

**@paramstuId*学⽣编号*@returnthestudent*@throwsSQLException*theSQLexception*/publicStudentselectStudentById(intstuId)throwsSQLException;/***查询所有学⽣基本信息.**@returnthelist*@throwsSQLException*theSQLexception*/publicListselectStudentAll()throwsSQLException;}com.laolang.dao.impl(数据库操作实现)StudentDaoImplpackagecom.laolang.dao.impl;importjava.sql.SQLException;importjava.util.ArrayList;importjava.util.List;importmons.dbutils.QueryRunner;importmons.dbutils.handlers.BeanHandler;importmons.dbutils.handlers.BeanListHandler;importcom.laolang.dao.StudentDao;importcom.laolang.db.laolangDB;importcom.laolang.domain.Student;/***数据库操作实现*/publicclassStudentDaoImplimplementsStudentDao{/**dbutils⼯具类对象*/

privateQueryRunnerrunner;/***Instantiatesanewstudentdaoimpl.*/publicStudentDaoImpl(){runner=newQueryRunner();}/**插⼊学⽣信息**@seecom.laolang.dao.StudentDao#insertStudent(com.laolang.domain.Student)*/@OverridepublicvoidinsertStudent(Studentstu)throwsSQLException{StringinsertStudent="insertintostudent(stuId,stuName,stuAge,stuSex)values(?,?,?,?)";runner.update(laolangDB.getConnection(),insertStudent,stu.getStuId(),stu.getStuName(),stu.getStuAge(),stu.getStuSex());}/**删除学⽣信息**@seecom.laolang.dao.StudentDao#deleteStudent(int)*/@OverridepublicvoiddeleteStudent(intstuId)throwsSQLException{StringdeleteStudentById="deletefromstudentwherestuId=?";runner.update(laolangDB.getConnection(),deleteStudentById,stuId);}/**更新学⽣基本信息**@seecom.laolang.dao.StudentDao#updateStudent(com.laolang.domain.Student)*//*

*(non-Javadoc)**@seecom.laolang.dao.StudentDao#updateStudent(com.laolang.domain.Student)*/@OverridepublicvoidupdateStudent(Studentstu)throwsSQLException{StringupdateStudent="updatestudentsetstuName=?,stuAge=?,stuSex=?wherestuId=?";runner.update(laolangDB.getConnection(),updateStudent,stu.getStuName(),stu.getStuAge(),stu.getStuSex(),stu.getStuId());}/**通过编号查询学⽣基本信息**@seecom.laolang.dao.StudentDao#selectStudentById(int)*/@OverridepublicStudentselectStudentById(intstuId)throwsSQLException{Studentstu=null;StringselectStudentById="selectstuName,stuAge,stuSexfromstudentwherestuId=?";stu=runner.query(laolangDB.getConnection(),selectStudentById,newBeanHandler(Student.class),stuId);stu.setStuId(stuId);returnstu;}/**查询所有学⽣基本信息**@seecom.laolang.dao.StudentDao#selectStudentAll()*/@OverridepublicListselectStudentAll()throwsSQLException{StringselectStudentAll="selectstuId,stuName,stuAge,stuSexfromstudent";ListstudentList=runner.query(laolangDB.getConnection(),

selectStudentAll,newBeanListHandler(Student.class));returnstudentList;}}界⾯部分:com.laolang.ui(界⾯部分全部在这个包⾥)ManagerMainWidnows.java(这是主界⾯,也是启动类)packagecom.laolang.ui;importjava.awt.BorderLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JScrollPane;importjavax.swing.JTable;importjavax.swing.JTextField;importcom.laolang.domain.Student;//TODO:Auto-generatedJavadoc/***功能:学⽣信息管理系统主界⾯版本:studentManager1.1.1作者:⼩代码**/publicclassManagerMainWindowextendsJFrameimplementsActionListener{/***Themainmethod.**@paramargs*thearguments*/publicstaticvoidmain(String[]args){ManagerMainWindowmmw=newManagerMainWindow();

}/***Instantiatesanewmanagermainwindow.*/publicManagerMainWindow(){init();this.setActionCommand();this.setTitle("学⽣信息管理系统");this.setSize(400,300);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setVisible(true);}/***初始化窗体*/privatevoidinit(){//创建组件this.lbId=newJLabel("待查学⽣编号");this.butInsert=newJButton("增加");this.butDelete=newJButton("删除");this.butUpdate=newJButton("修改");this.butSelect=newJButton("查询");this.butShowAll=newJButton("显⽰所有");this.tfId=newJTextField(10);this.jpNorth=newJPanel();this.jpSouth=newJPanel();this.stm=newStudentTableModel();stm.showAllData();this.jt=newJTable(stm);this.jsp=newJScrollPane(jt);//将组件添加到⾯板jpNorth.add(lbId);jpNorth.add(tfId);jpNorth.add(butSelect);

jpSouth.add(butInsert);jpSouth.add(butDelete);jpSouth.add(butUpdate);jpSouth.add(butShowAll);//将⾯板添加到窗体this.add(jpNorth,BorderLayout.NORTH);this.add(jsp,BorderLayout.CENTER);this.add(jpSouth,BorderLayout.SOUTH);}/***Setstheactioncommand.*/privatevoidsetActionCommand(){this.butInsert.addActionListener(this);this.butDelete.addActionListener(this);this.butUpdate.addActionListener(this);this.butSelect.addActionListener(this);this.butShowAll.addActionListener(this);this.butInsert.setActionCommand("insert");this.butDelete.setActionCommand("delete");this.butUpdate.setActionCommand("update");this.butSelect.setActionCommand("select");this.butShowAll.setActionCommand("show");}/**(non-Javadoc)事件处理**@see*java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)*/@OverridepublicvoidactionPerformed(ActionEvente){//如果⽤户点击添加if(e.getActionCommand().equals("insert")){

//System.out.println("insert");//弹出添加对话框,并得到添加对话框中输⼊的值Studentstu=newStudentInsertDialog(this,"添加学⽣信息",true).getStu();//如果没有点取消if(null!=stu){StudentTableModelstutm=newStudentTableModel();//⽣成新的modelstutm.insertStu(stu);//执⾏插⼊jt.setModel(stutm);//更新表格model}}//如果点击删除elseif(e.getActionCommand().equals("delete")){//System.out.println("delete");//得到⽤户选择的⾏的⾏号intdelIndex=jt.getSelectedRow();//如果没有选择任何⾏,则提醒选择⼀⾏if(-1==delIndex){JOptionPane.showMessageDialog(this,"请选择⼀⾏之后,再进⾏删除操作","警告",JOptionPane.WARNING_MESSAGE);}if(-1!=delIndex){StringidStr=(String)stm.getValueAt(delIndex,0);intid=Integer.valueOf(idStr).intValue();//System.out.println(id);StudentTableModelstuTm=newStudentTableModel();//⽣成亲的modelstuTm.deleteStu(id);//执⾏删除jt.setModel(stuTm);//更新表格model}}//如果⽤户选择更新elseif(e.getActionCommand().equals("update")){//System.out.println("update");//得到⽤户选择的⾏的⾏号

intupdataRowIndex=this.jt.getSelectedRow();//如果没有选择任何⾏,则提醒选择⼀⾏if(-1==updataRowIndex){JOptionPane.showMessageDialog(this,"请选择⼀⾏之后,再进⾏修改操作","警告",JOptionPane.WARNING_MESSAGE);}if(-1!=updataRowIndex){Studentstu=newStudent();stu.setStuId(Integer.valueOf((String)stm.getValueAt(updataRowIndex,0)).intValue());stu.setStuName((String)stm.getValueAt(updataRowIndex,1));stu.setStuAge(Integer.valueOf((String)stm.getValueAt(updataRowIndex,2)).intValue());stu.setStuSex((String)stm.getValueAt(updataRowIndex,3));stu=newStudentUpdateDialog(this,"修改学⽣信息",true,stu).getStu();//如果修改了学⽣信息,则更新if(null!=null){StudentTableModelstutm=newStudentTableModel();//万籁新的modelstutm.updateStu(stu);//执⾏更新jt.setModel(stutm);//更新表格model//System.out.println(stu.toString());}}}//如果选择查询elseif(e.getActionCommand().equals("select")){//System.out.println("select");//得到输⼊的学⽣编号intid=Integer.valueOf(tfId.getText()).intValue();StudentTableModelstutm=newStudentTableModel();//⽣成新modelstutm.selectStuId(id);//执⾏查询jt.setModel(stutm);//更新表格model}

//如果选择显⽰所有elseif(e.getActionCommand().equals("show")){//System.out.println("show");StudentTableModelstutm=newStudentTableModel();//⽣成新的modelstutm.showAllData();//执⾏显⽰所有jt.setModel(stutm);//更新表格model}}/**输⼊编号标签*/privateJLabellbId;/**接收编号的输⼊框*/privateJTextFieldtfId;/**插⼊按钮*/privateJButtonbutInsert;/**删除按钮*/privateJButtonbutDelete;/**更新按钮*/privateJButtonbutUpdate;/**查询按钮*/privateJButtonbutSelect;/**显⽰所有按钮*/privateJButtonbutShowAll;/**滚动窗格*/privateJScrollPanejsp;/**表格*/privateJTablejt;/**⽤于初始化表格的model*/privateStudentTableModelstm;/**北部paenl*/privateJPaneljpNorth;/**南部paenl*/privateJPaneljpSouth;}StudentTableModel.java(表格model)

packagecom.laolang.ui;importjava.sql.SQLException;importjava.util.List;importjava.util.Vector;importjavax.swing.table.AbstractTableModel;importcom.laolang.dao.StudentDao;importcom.laolang.dao.impl.StudentDaoImpl;importcom.laolang.domain.Student;//TODO:Auto-generatedJavadoc/***主窗⼝中,表格模型*/publicclassStudentTableModelextendsAbstractTableModel{/***Instantiatesanewstudenttablemodel.*/publicStudentTableModel(){init();}/***初始化,只完成表头部分*/privatevoidinit(){rowData=newVector();colunmNames=newVector();colunmNames.add("编号");colunmNames.add("姓名");colunmNames.add("年龄");colunmNames.add("性别");}/***添加**@paramstuthestu

*/publicvoidinsertStu(Studentstu){try{sDao.insertStudent(stu);showAllData();}catch(SQLExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}}/***删除**@paramidtheid*/publicvoiddeleteStu(intid){try{sDao.deleteStudent(id);showAllData();}catch(SQLExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}}/***更新**@paramstuthestu*/publicvoidupdateStu(Studentstu){try{sDao.updateStudent(stu);showAllData();}catch(SQLExceptione){

//TODOAuto-generatedcatchblocke.printStackTrace();}}/***查询**@paramidtheid*@returnthestudent*/publicStudentselectStuId(intid){Studentstu=null;try{stu=sDao.selectStudentById(id);VectorstuV=newVector();stuV.add(String.valueOf(stu.getStuId()));stuV.add(stu.getStuName());stuV.add(String.valueOf(stu.getStuAge()));stuV.add(stu.getStuSex());rowData.add(stuV);}catch(SQLExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}returnstu;}/***显⽰所有*/publicvoidshowAllData(){if(0!=rowData.size()){rowData.clear();}try{

ListstuList=sDao.selectStudentAll();for(Studentstu:stuList){VectorstuV=newVector();stuV.add(String.valueOf(stu.getStuId()));stuV.add(stu.getStuName());stuV.add(String.valueOf(stu.getStuAge()));stuV.add(stu.getStuSex());rowData.add(stuV);}}catch(SQLExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}}/*(non-Javadoc)*设置表头*@seejavax.swing.table.AbstractTableModel#getColumnName(int)*/@OverridepublicStringgetColumnName(intcolumn){return(String)colunmNames.get(column);}/*(non-Javadoc)*得到共有多少⾏*@seejavax.swing.table.TableModel#getRowCount()*/@OverridepublicintgetRowCount(){returnrowData.size();}/*(non-Javadoc)*得到共有多少列*@seejavax.swing.table.TableModel#getColumnCount()*/

@OverridepublicintgetColumnCount(){returncolunmNames.size();}/*(non-Javadoc)*得到某⾏某列的数据*@seejavax.swing.table.TableModel#getValueAt(int,int)*/@OverridepublicObjectgetValueAt(introwIndex,intcolumnIndex){return((Vector)rowData.get(rowIndex)).get(columnIndex);}/**Therowdata.*/privateVectorrowData;/**Thecolunmnames.*/privateVectorcolunmNames;/**Thesdao.*/publicstaticfinalStudentDaosDao=newStudentDaoImpl();}StudentInsertDialog(添加数据对话框)packagecom.laolang.ui;importjava.awt.BorderLayout;importjava.awt.FlowLayout;importjava.awt.Frame;importjava.awt.GridLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjavax.swing.JButton;importjavax.swing.JDialog;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JPanel;importjavax.swing.JTextField;importcom.laolang.domain.Student;

/***添加学⽣信息对话框*/publicclassStudentInsertDialogextendsJDialogimplementsActionListener{/***Instantiatesanewstudentinsertdialog.*/publicStudentInsertDialog(){super();}/***Instantiatesanewstudentinsertdialog.**@paramowner*theowner*@paramtitle*thetitle*@parammodal*themodal*/publicStudentInsertDialog(Frameowner,Stringtitle,booleanmodal){super(owner,title,modal);init();setComm();this.setSize(300,180);this.setVisible(true);this.setResizable(false);}/***初始化*/privatevoidinit(){//创建组件this.labelId=newJLabel("编号");

this.labelName=newJLabel("姓名");this.labelAge=newJLabel("年龄");this.labelSex=newJLabel("性别");this.tfId=newJTextField(20);this.tfName=newJTextField(20);this.tfAge=newJTextField(20);this.tfSex=newJTextField(20);this.butOk=newJButton("确定");this.butCanel=newJButton("取消");this.jpCenterLeft=newJPanel();this.jpCenterRight=newJPanel();this.jpCenter=newJPanel();this.jpSouth=newJPanel();//设置布局this.setLayout(newBorderLayout());this.jpCenterLeft.setLayout(newGridLayout(6,1));this.jpCenterRight.setLayout(newGridLayout(6,1));this.jpCenter.setLayout(newFlowLayout());this.jpSouth.setLayout(newFlowLayout());//添加组件到⾯板this.jpCenterLeft.add(this.labelId);this.jpCenterLeft.add(this.labelName);this.jpCenterLeft.add(this.labelAge);this.jpCenterLeft.add(this.labelSex);this.jpCenterRight.add(this.tfId);this.jpCenterRight.add(this.tfName);this.jpCenterRight.add(this.tfAge);this.jpCenterRight.add(this.tfSex);this.jpCenter.add(this.jpCenterLeft);this.jpCenter.add(this.jpCenterRight);this.jpSouth.add(this.butOk);this.jpSouth.add(this.butCanel);//⾯板添加到窗体this.add(this.jpCenter);

this.add(this.jpSouth,BorderLayout.SOUTH);}/***注册监听、设置命令.*/privatevoidsetComm(){this.butOk.addActionListener(this);this.butCanel.addActionListener(this);this.butOk.setActionCommand("ok");this.butCanel.setActionCommand("canel");}/**(non-Javadoc)事件处理**@see*java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)*/@OverridepublicvoidactionPerformed(ActionEvente){if(e.getActionCommand().equals("ok")){//如果点击确定,则创建⼀个Student对象,并对各个属性赋值this.stu=newStudent();this.stu.setStuId(Integer.valueOf(this.tfId.getText()).intValue());this.stu.setStuName(this.tfName.getText());this.stu.setStuAge(Integer.valueOf(this.tfAge.getText()).intValue());this.stu.setStuSex(this.tfSex.getText());//隐藏对话框this.setVisible(false);}elseif(e.getActionCommand().equals("canel")){//如果点击取消,则置Student为空this.stu=null;//隐藏对话框this.setVisible(false);}

}/**Thelabelid.*/privateJLabellabelId;/**Thelabelname.*/privateJLabellabelName;/**Thelabelage.*/privateJLabellabelAge;/**Thelabelsex.*/privateJLabellabelSex;/**Thetfid.*/privateJTextFieldtfId;/**Thetfname.*/privateJTextFieldtfName;/**Thetfage.*/privateJTextFieldtfAge;/**Thetfsex.*/privateJTextFieldtfSex;/**Thebutok.*/privateJButtonbutOk;/**Thebutcanel.*/privateJButtonbutCanel;/**Thejpcenterleft.*/privateJPaneljpCenterLeft;/**Thejpcenterright.*/privateJPaneljpCenterRight;/**Thejpcenter.*/privateJPaneljpCenter;/**Thejpsouth.*/privateJPaneljpSouth;/**Thestu.*/privateStudentstu;/***Getsthestu.*

*@returnthestu*/publicStudentgetStu(){returnstu;}}StudentUpdateDialog(修改数据对话框)packagecom.laolang.ui;importjava.awt.BorderLayout;importjava.awt.FlowLayout;importjava.awt.Frame;importjava.awt.GridLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjavax.swing.JButton;importjavax.swing.JDialog;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JPanel;importjavax.swing.JTextField;importcom.laolang.domain.Student;//TODO:Auto-generatedJavadoc/***学⽣信息更新对话框本类有⼀个Student对象,⽤于记录各输⼊框中的值*/publicclassStudentUpdateDialogextendsJDialogimplementsActionListener{/***Instantiatesanewstudentinsertdialog.*/publicStudentUpdateDialog(){super();}/***Instantiatesanewstudentinsertdialog.

**@paramowner*theowner*@paramtitle*thetitle*@parammodal*themodal*@paramstu*thestu*/publicStudentUpdateDialog(Frameowner,Stringtitle,booleanmodal,Studentstu){super(owner,title,modal);init(stu);setComm();setSize(300,180);setVisible(true);setResizable(false);}/***创建各组件**@params*thes*/privatevoidinit(Students){stu=newStudent();//创建Student对象//设置各属性值为选中⾏的相应的值stu.setStuId(s.getStuId());stu.setStuName(s.getStuName());stu.setStuAge(s.getStuAge());stu.setStuSex(s.getStuSex());//创建组件labelId=newJLabel("编号");

labelName=newJLabel("姓名");labelAge=newJLabel("年龄");labelSex=newJLabel("性别");tfId=newJTextField(String.valueOf(stu.getStuId()),20);tfId.setEditable(false);tfName=newJTextField(stu.getStuName(),20);tfAge=

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论