JAVA程序设计学生考勤管理系统课程名称:JAVA程序设计设计题目:学生考勤管理系统(JAVA)指导老师:XXX班级:数计X级X班姓名:XXX学号:XXXXXXXXXX时间:2016年某月某日编程工具:MyEclipse(盗版的)编程电脑:DELL操作系统:Windows7(自己换的)显卡:NVIDIA编程环境:JAVA语言设计功能:查看学生信息学生考勤增加,删除,修改学生信息实验代码:packagemanger;importjavax.swing.JDialog;importjavax.swing.JFrame;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjava.awt.BorderLayout;importjava.awt.Dimension;importjava.awt.Toolkit;importjavax.swing.JDesktopPane;importjavax.swing.JButton;importjava.awt.Rectangle;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.Statement;importjavax.swing.JTextField;importjavax.swing.JLabel;publicclassAddForm{privateJFramejFrame=null;privateJPaneljContentPane=null;privateJDesktopPanejDesktopPane=null;privateJButtonjButtonOK=null;privateJButtonjButtonCancel=null;privateJTextFieldjTextName=null;privateJTextFieldjTextNum=null;privateJTextFieldjTextGrade=null;privateJLabeljLabelName=null;privateJLabeljLabelNum=null;privateJLabeljLabelGrade=null;JFramegetJFrame(){if(jFrame==null){jFrame=newJFrame();jFrame.setTitle(添加学生信息);jFrame.setSize(newDimension(242,205));DimensionscreenSize=Toolkit.getDefaultToolkit().getScreenSize();//窗口居中显示screenSize=Toolkit.getDefaultToolkit().getScreenSize();jFrame.setLocation((screenSize.width-jFrame.getWidth())/2,(screenSize.height-jFrame.getHeight())/2);jFrame.setContentPane(getJContentPane());}returnjFrame;}privateJPanelgetJContentPane(){if(jContentPane==null){jContentPane=newJPanel();jContentPane.setLayout(newBorderLayout());jContentPane.add(getJDesktopPane(),BorderLayout.CENTER);}returnjContentPane;}privateJDesktopPanegetJDesktopPane(){if(jDesktopPane==null){jLabelGrade=newJLabel();jLabelGrade.setBounds(newRectangle(30,100,38,18));jLabelGrade.setText(班级:);jLabelNum=newJLabel();jLabelNum.setBounds(newRectangle(30,60,38,18));jLabelNum.setText(学号:);jLabelName=newJLabel();jLabelName.setBounds(newRectangle(30,20,38,18));jLabelName.setText(姓名:);jDesktopPane=newJDesktopPane();jDesktopPane.add(getJButtonOK(),null);jDesktopPane.add(getJButtonCancel(),null);jDesktopPane.add(getJTextName(),null);jDesktopPane.add(getJTextNum(),null);jDesktopPane.add(getJTextGrade(),null);jDesktopPane.add(jLabelName,null);jDesktopPane.add(jLabelNum,null);jDesktopPane.add(jLabelGrade,null);}returnjDesktopPane;}privateJButtongetJButtonOK(){if(jButtonOK==null){jButtonOK=newJButton();jButtonOK.setBounds(newRectangle(20,135,80,22));jButtonOK.setText(提交);jButtonOK.addMouseListener(newjava.awt.event.MouseAdapter(){publicvoidmouseClicked(java.awt.event.MouseEvente){try{AddSQL();}catch(Exceptione1){//TODO自动生成catch块e1.printStackTrace();}//TODOAuto-generatedEventstubmouseClicked()}privatevoidAddSQL()throwsException{StringDBDriver=sun.jdbc.odbc.JdbcOdbcDriver;StringStr=jdbc:odbc:driver={MicrosoftAccessDriver(*.mdb)};DBQ=StuInfo;Connectioncon=null;Statementstmt=null;ResultSetrs=null;Class.forName(DBDriver);con=DriverManager.getConnection(Str);stmt=con.createStatement();Stringname=jTextName.getText();if(name.equals()){stmt.close();con.close();JOptionPane.showMessageDialog(newJDialog(),姓名不能为空!);return;}Stringnum=jTextNum.getText();if(num.equals()){stmt.close();con.close();JOptionPane.showMessageDialog(newJDialog(),学号不能为空!);return;}else{rs=stmt.executeQuery(Select*FromStuInfowhereNum='+num+');if(rs.next()){stmt.close();con.close();JOptionPane.showMessageDialog(newJDialog(),学号重复!);return;}}Stringgrade=jTextGrade.getText();if(grade.equals()){stmt.close();con.close();JOptionPane.showMessageDialog(newJDialog(),班级不能为空!);return;}stmt.executeUpdate(InsertIntoStuInfoValues('+name+','+num+','+grade+'));stmt.close();con.close();MainForm.Reflesh();getJFrame().dispose();JOptionPane.showMessageDialog(newJDialog(),添加成功!);}});}returnjButtonOK;}privateJButtongetJButtonCancel(){if(jButtonCancel==null){jButtonCancel=newJButton();jButtonCancel.setBounds(newRectangle(137,135,80,22));jButtonCancel.setText(取消);jButtonCancel.addMouseListener(newjava.awt.event.MouseAdapter(){publicvoidmouseClicked(java.awt.event.MouseEvente){getJFrame().dispose();}});}returnjButtonCancel;}privateJTextFieldgetJTextName(){if(jTextName==null){jTextName=newJTextField();jTextName.setBounds(newRectangle(90,20,120,22));}returnjTextName;}privateJTextFieldgetJTextNum(){if(jTextNum==null){jTextNum=newJTextField();jTextNum.setBounds(newRectangle(90,60,120,22));}returnjTextNum;}privateJTextFieldgetJTextGrade(){if(jTextGrade==null){jTextGrade=newJTextField();jTextGrade.setBounds(newRectangle(90,100,120,22));}returnjTextGrade;}}程序效果:未知错误:应用程序无法正常启动,请单击“确定”以关闭该程序;