您好,欢迎光临本网站![请登录][注册会员]  
文件名称: java教务管理系统
  所属分类: Java
  开发工具:
  文件大小: 2mb
  下载次数: 0
  上传时间: 2012-04-08
  提 供 者: aa244******
 详细说明: 课程设计,大家可以参考参考 package login; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import javax.swing.JOptionPane; import student.*; import teacher.*; public class LoginFrame extends javax.swing.JFrame { /** Creates new form LoginFrame */ public LoginFrame() { initComponents(); //初始化图形界面 } String admin; String pass; String ident; /** This method is called from within the constructor to * initialize the form. * WARNI NG: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // private void initComponents() { //各个组件的初始化 jLayeredPane1 = new javax.swing.JLayeredPane(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jTextField2 = new javax.swing.JPasswordField(); jTextField1 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jComboBox1 = new javax.swing.JComboBox(); jLabel1 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setBackground(new java.awt.Color(255, 255, 255)); jLayeredPane1.setBackground(new java.awt.Color(255, 204, 204)); jLabel2.setText("用户帐号:"); jLabel2.setBounds(70, 140, 70, 30); jLayeredPane1.add(jLabel2, javax.swing.JLayeredPane.DEFAULT_LAYER); jLabel3.setText("密码:"); jLabel3.setBounds(70, 180, 36, 15); jLayeredPane1.add(jLabel3, javax.swing.JLayeredPane.DEFAULT_LAYER); jTextField2.setBounds(140, 170, 140, 21); jLayeredPane1.add(jTextField2, javax.swing.JLayeredPane.DEFAULT_LAYER); jTextField1.setBounds(140, 140, 140, 21); jLayeredPane1.add(jTextField1, javax.swing.JLayeredPane.DEFAULT_LAYER); jButton1.setText("登陆"); jButton1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton1.setBounds(120, 215, 70, 23); jLayeredPane1.add(jButton1, javax.swing.JLayeredPane.DEFAULT_LAYER); jButton2.setText("取消"); jButton2.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jButton2.setBounds(210, 215, 80, 21); jLayeredPane1.add(jButton2, javax.swing.JLayeredPane.DEFAULT_LAYER); jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "学生", "教师" })); jComboBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); jComboBox1.setBounds(310, 140, 62, 21); jLayeredPane1.add(jComboBox1, javax.swing.JLayeredPane.DEFAULT_LAYER); jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/login/11.jpg"))); // NOI18N jLabel1.setText("用户帐号"); jLabel1.setBounds(0,0,425,265); jLayeredPane1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER); //组件布局的管理 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 576, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 453, javax.swing.GroupLayout.PREFERRED_SIZE) ); pack(); }// private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { //按钮监听器 // TODO add your handling code here: admin=jTextField1.getText(); //从文本框中获取用户账号 pass=jTextField2.getText(); // 从文本框获取用户密码 ident=jComboBox1.getSelectedItem()+""; //从下拉组件中获取Item,教师或者学生确定身份 // System.out.print(admin+pass+ident); if (admin==null||admin.equals("")){ // 判断账号是否为空 JOptionPane.showMessageDialog(jTextField1,"请输入帐号"); //账号为空时提示警告 }else if (pass==null||pass.equals("")){ JOptionPane.showMessageDialog(jTextField1,"请输入密码"); //密码为空时提示警告 }else { try{ Connection conn = null; //装载驱动 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //连接数据库 conn=DriverManager.getConnection("jdbc:odbc:Pubs","scott","tiger"); //查询准备 Statement stmt = conn.createStatement(); String qstr = "select ident,admin,pw from ap where ident ='"+ident+"'and admin='"+admin+"'and pw='"+pass+"'"; //查询 ResultSet rs = stmt.executeQuery(qstr); //处理结果 if(rs.next()){ String ident=rs.getString("ident"); if (ident.equals("学生")){ dispose(); new StudentFrame(admin); } else if (ident.equals("教师")){ dispose(); new TeacherFrame(admin); } }else {JOptionPane.showMessageDialog(jTextField1,"帐号或密码错误请重新输入");} //关闭结果集、查询语句、数据库连接,释放内存资源 rs.close();stmt.close();conn.close(); }catch(Exception ex){ System.out.println(ex.getMessage()); } } } //相应组件的监听器 private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: System.exit(0); //退出按钮的监听 } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ // /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(LoginFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(LoginFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(LoginFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(LoginFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } // /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { LoginFrame fr = new LoginFrame(); fr.setResizable(false); fr.setVisible(true); fr.setTitle("教务管理系统"); fr.setBounds(400,200,428,295); } }); } // 所需变量的声明,没有初始化 public javax.swing.JButton jButton1; public javax.swing.JButton jButton2; public javax.swing.JComboBox jComboBox1; public javax.swing.JLabel jLabel1; public javax.swing.JLabel jLabel2; public javax.swing.JLabel jLabel3; public javax.swing.JLayeredPane jLayeredPane1; public javax.swing.JTextField jTextField1; public javax.swing.JTextField jTextField2; // End of variables declaration } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: java sql
 输入关键字,在本站1000多万海量源码库中尽情搜索: