版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
?java輸出學(xué)?信息表代碼_學(xué)?信息管理系統(tǒng)JAVASE版--1.1.1現(xiàn)在終于可以寫(xiě)出實(shí)??點(diǎn)的程序了。雖然這個(gè)程序的功能?常之簡(jiǎn)陋,?且還有BUG。不過(guò)最起碼已經(jīng)可以使?了。功能預(yù)覽和下?步的?標(biāo)程序主界?查詢功能:?前只做了?個(gè)表的增、刪、改、查。下?步應(yīng)該就是把功能完善,?如加?錯(cuò)誤處理,?如加?成績(jī)部分。完成?個(gè)班級(jí)內(nèi)的學(xué)?信息管理的功能,應(yīng)該具有學(xué)?的基本信息查詢,成績(jī)管理這兩個(gè)功能不過(guò)有?個(gè)問(wèn)題就是,在表格更新這?部分,每更新?次,就要?jiǎng)?chuàng)建?個(gè)tabliModel對(duì)象,感覺(jué)可以改進(jìn)。再有就是MVC模式,其實(shí)也就接觸設(shè)計(jì)模式。還有就是整成那種可執(zhí)??件。程序代碼mysql建表語(yǔ)句CREATETABLEstudent(stuIdINTPRIMARYKEY,stuNameVARCHAR(20)NOTNULLDEFAULT'',stuAgeINTNOTNULLDEFAULT0,stuSexVARCHAR(5)NOTNULLDEFAULT'')enginemyisamcharsetutf8;JAVA代碼:數(shù)據(jù)庫(kù)部分com.laolang.domain(數(shù)據(jù)對(duì)象,這?只有?個(gè)Student對(duì)象)packagecom.laolang.domain;/***學(xué)?對(duì)象,對(duì)應(yīng)數(shù)據(jù)庫(kù)中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;}/**學(xué)?編號(hào)*/privateintstuId;/**學(xué)?姓名*/privateStringstuName;/**學(xué)?年齡*/privateintstuAge;/**學(xué)?性別*/privateStringstuSex;}com.laolang.db(數(shù)據(jù)庫(kù)連接?具類(lèi),?的是屬性?件的?式)laolangDB(?具類(lèi))packagecom.laolang.db;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;importjava.util.ResourceBundle;/***數(shù)據(jù)庫(kù)連接和關(guān)閉?具類(lèi)*/publicclasslaolangDB{/**數(shù)據(jù)庫(kù)連接地址*/privatestaticStringURL;/**數(shù)據(jù)庫(kù)?戶名*/privatestaticStringUSERNAME;/**數(shù)據(jù)庫(kù)密碼*/
privatestaticStringUSERPASSWORD;/**mysql驅(qū)動(dòng)*/privatestaticStringDRIVER;/**Therb.*/privatestaticResourceBundlerb=ResourceBundle.getBundle("com.laolang.db.db-config");/***使?靜態(tài)代碼塊加載驅(qū)動(dòng)*/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;}/***關(guān)閉鏈接.**@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(數(shù)據(jù)?件):jdbc.url=jdbc:mysql://localhost:3306/studentmanager1.1.1jdbc.username=rootjdbc.userpassword=123456jdbc.driver=com.mysql.jdbc.Drivercom.laolang.dao(數(shù)據(jù)庫(kù)操作接?)StudentDaopackagecom.laolang.dao;importjava.sql.SQLException;importjava.util.List;
importcom.laolang.domain.Student;/***數(shù)據(jù)庫(kù)操作接?*/publicinterfaceStudentDao{/***插?學(xué)?基本信息.**@paramstu*學(xué)?對(duì)象*@throwsSQLException*theSQLexception*/publicvoidinsertStudent(Studentstu)throwsSQLException;/***刪除學(xué)?基本信息.**@paramstuId*學(xué)?編號(hào)*@throwsSQLException*theSQLexception*/publicvoiddeleteStudent(intstuId)throwsSQLException;/***更新學(xué)?基本信息.**@paramstu*學(xué)?對(duì)象*@throwsSQLException*theSQLexception*/publicvoidupdateStudent(Studentstu)throwsSQLException;/***S通過(guò)編號(hào)查詢學(xué)?基本信息.
**@paramstuId*學(xué)?編號(hào)*@returnthestudent*@throwsSQLException*theSQLexception*/publicStudentselectStudentById(intstuId)throwsSQLException;/***查詢所有學(xué)?基本信息.**@returnthelist*@throwsSQLException*theSQLexception*/publicListselectStudentAll()throwsSQLException;}com.laolang.dao.impl(數(shù)據(jù)庫(kù)操作實(shí)現(xiàn))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;/***數(shù)據(jù)庫(kù)操作實(shí)現(xiàn)*/publicclassStudentDaoImplimplementsStudentDao{/**dbutils?具類(lèi)對(duì)象*/
privateQueryRunnerrunner;/***Instantiatesanewstudentdaoimpl.*/publicStudentDaoImpl(){runner=newQueryRunner();}/**插?學(xué)?信息**@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());}/**刪除學(xué)?信息**@seecom.laolang.dao.StudentDao#deleteStudent(int)*/@OverridepublicvoiddeleteStudent(intstuId)throwsSQLException{StringdeleteStudentById="deletefromstudentwherestuId=?";runner.update(laolangDB.getConnection(),deleteStudentById,stuId);}/**更新學(xué)?基本信息**@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());}/**通過(guò)編號(hào)查詢學(xué)?基本信息**@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;}/**查詢所有學(xué)?基本信息**@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(界?部分全部在這個(gè)包?)ManagerMainWidnows.java(這是主界?,也是啟動(dòng)類(lèi))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/***功能:學(xué)?信息管理系統(tǒng)主界?版本:studentManager1.1.1作者:?代碼**/publicclassManagerMainWindowextendsJFrameimplementsActionListener{/***Themainmethod.**@paramargs*thearguments*/publicstaticvoidmain(String[]args){ManagerMainWindowmmw=newManagerMainWindow();
}/***Instantiatesanewmanagermainwindow.*/publicManagerMainWindow(){init();this.setActionCommand();this.setTitle("學(xué)?信息管理系統(tǒng)");this.setSize(400,300);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setVisible(true);}/***初始化窗體*/privatevoidinit(){//創(chuàng)建組件this.lbId=newJLabel("待查學(xué)?編號(hào)");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){//如果?戶點(diǎn)擊添加if(e.getActionCommand().equals("insert")){
//System.out.println("insert");//彈出添加對(duì)話框,并得到添加對(duì)話框中輸?的值Studentstu=newStudentInsertDialog(this,"添加學(xué)?信息",true).getStu();//如果沒(méi)有點(diǎn)取消if(null!=stu){StudentTableModelstutm=newStudentTableModel();//?成新的modelstutm.insertStu(stu);//執(zhí)?插?jt.setModel(stutm);//更新表格model}}//如果點(diǎn)擊刪除elseif(e.getActionCommand().equals("delete")){//System.out.println("delete");//得到?戶選擇的?的?號(hào)intdelIndex=jt.getSelectedRow();//如果沒(méi)有選擇任何?,則提醒選擇??if(-1==delIndex){JOptionPane.showMessageDialog(this,"請(qǐng)選擇??之后,再進(jìn)?刪除操作","警告",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);//執(zhí)?刪除jt.setModel(stuTm);//更新表格model}}//如果?戶選擇更新elseif(e.getActionCommand().equals("update")){//System.out.println("update");//得到?戶選擇的?的?號(hào)
intupdataRowIndex=this.jt.getSelectedRow();//如果沒(méi)有選擇任何?,則提醒選擇??if(-1==updataRowIndex){JOptionPane.showMessageDialog(this,"請(qǐng)選擇??之后,再進(jìn)?修改操作","警告",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,"修改學(xué)?信息",true,stu).getStu();//如果修改了學(xué)?信息,則更新if(null!=null){StudentTableModelstutm=newStudentTableModel();//萬(wàn)籟新的modelstutm.updateStu(stu);//執(zhí)?更新jt.setModel(stutm);//更新表格model//System.out.println(stu.toString());}}}//如果選擇查詢elseif(e.getActionCommand().equals("select")){//System.out.println("select");//得到輸?的學(xué)?編號(hào)intid=Integer.valueOf(tfId.getText()).intValue();StudentTableModelstutm=newStudentTableModel();//?成新modelstutm.selectStuId(id);//執(zhí)?查詢jt.setModel(stutm);//更新表格model}
//如果選擇顯?所有elseif(e.getActionCommand().equals("show")){//System.out.println("show");StudentTableModelstutm=newStudentTableModel();//?成新的modelstutm.showAllData();//執(zhí)?顯?所有jt.setModel(stutm);//更新表格model}}/**輸?編號(hào)標(biāo)簽*/privateJLabellbId;/**接收編號(hào)的輸?框*/privateJTextFieldtfId;/**插?按鈕*/privateJButtonbutInsert;/**刪除按鈕*/privateJButtonbutDelete;/**更新按鈕*/privateJButtonbutUpdate;/**查詢按鈕*/privateJButtonbutSelect;/**顯?所有按鈕*/privateJButtonbutShowAll;/**滾動(dòng)窗格*/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("編號(hào)");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)*設(shè)置表頭*@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)*得到某?某列的數(shù)據(jù)*@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(添加數(shù)據(jù)對(duì)話框)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;
/***添加學(xué)?信息對(duì)話框*/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(){//創(chuàng)建組件this.labelId=newJLabel("編號(hào)");
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();//設(shè)置布局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);}/***注冊(cè)監(jiān)聽(tīng)、設(shè)置命令.*/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")){//如果點(diǎn)擊確定,則創(chuàng)建?個(gè)Student對(duì)象,并對(duì)各個(gè)屬性賦值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());//隱藏對(duì)話框this.setVisible(false);}elseif(e.getActionCommand().equals("canel")){//如果點(diǎn)擊取消,則置Student為空this.stu=null;//隱藏對(duì)話框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(修改數(shù)據(jù)對(duì)話框)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/***學(xué)?信息更新對(duì)話框本類(lèi)有?個(gè)Student對(duì)象,?于記錄各輸?框中的值*/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);}/***創(chuàng)建各組件**@params*thes*/privatevoidinit(Students){stu=newStudent();//創(chuàng)建Student對(duì)象//設(shè)置各屬性值為選中?的相應(yīng)的值stu.setStuId(s.getStuId());stu.setStuName(s.getStuName());stu.setStuAge(s.getStuAge());stu.setStuSex(s.getStuSex());//創(chuàng)建組件labelId=newJLabel("編號(hào)");
labelName=newJLabel("姓名");labelAge=newJLabel("年齡");labelSex=newJLabel("性別");tfId=newJTextField(String.valueOf(stu.getStuId()),20);tfId.setEditable(false);tfName=newJTextField(stu.getStuName(),20);tfAge=
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 《從傳統(tǒng)到時(shí)尚》課件
- 七大洲四大洋的位置
- 山東省煙臺(tái)市招遠(yuǎn)市(五四學(xué)制)2024-2025學(xué)年九年級(jí)上學(xué)期期末考試道德與法治試卷(含答案)
- 2024年全國(guó)社會(huì)工作者初級(jí)職業(yè)水平《社會(huì)工作實(shí)務(wù)》考試題參考答案
- 單位管理制度展示合集【人事管理篇】
- 單位管理制度展示大合集職員管理十篇
- 定期報(bào)告:一月可能繼續(xù)震蕩偏強(qiáng)中小盤(pán)成長(zhǎng)占優(yōu)
- 2024-2030年中國(guó)偶氮顏料行業(yè)市場(chǎng)深度分析及發(fā)展趨勢(shì)預(yù)測(cè)報(bào)告
- 單位管理制度展示大合集職工管理篇十篇
- 單位管理制度品讀選集【員工管理篇】
- 網(wǎng)絡(luò)賭博、網(wǎng)絡(luò)借貸和網(wǎng)絡(luò)詐騙的危害
- 《中西醫(yī)的區(qū)別》課件
- RFID電子標(biāo)簽制作方法
- 智能制造企業(yè)數(shù)字化轉(zhuǎn)型建設(shè)方案
- 病理生理學(xué)課件脂代謝紊亂
- 教師幽默朗誦節(jié)目《我愛(ài)上班》
- 《細(xì)胞工程學(xué)》考試復(fù)習(xí)題庫(kù)(帶答案)
- 中學(xué)課堂教學(xué)評(píng)價(jià)量表
- 食堂食材配送以及售后服務(wù)方案
- 塊單項(xiàng)活動(dòng)教學(xué)材料教案丹霞地貌
- 青年人應(yīng)該如何樹(shù)立正確的人生觀
評(píng)論
0/150
提交評(píng)論