⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logindialog.java~9~

📁 简单的学生管理系统。。用JBUILER和SQL2000。
💻 JAVA~9~
字号:
package studentgl;import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class LoginDialog extends JDialog {  JPanel panel1 = new JPanel();  JLabel jLabel1 = new JLabel();  JLabel jLabel2 = new JLabel();  JLabel jLabel3 = new JLabel();  JTextField jTextField1 = new JTextField();  JPasswordField jPasswordField1 = new JPasswordField();  JButton jButton1 = new JButton();  JButton jButton2 = new JButton();  private  Connection con;  private  mainFrame Frame1;  private  Statement stmt;  public LoginDialog(mainFrame frame, String title, boolean modal) {    super(frame, title, modal);     this.setLocation(309,239);    Frame1=frame;    try {      jbInit();      pack();    }    catch(Exception ex) {      ex.printStackTrace();    }  }  public LoginDialog() {    this(null, "", false);  }  private void jbInit() throws Exception {    panel1.setLayout(null);    jLabel1.setFont(new java.awt.Font("Serif", 1, 25));    jLabel1.setForeground(SystemColor.textHighlight);    jLabel1.setHorizontalAlignment(SwingConstants.CENTER);    jLabel1.setText("请输入学号和密码");    jLabel1.setBounds(new Rectangle(-1, 15, 402, 52));    jLabel2.setFont(new java.awt.Font("Serif", 1, 16));    jLabel2.setForeground(Color.red);    jLabel2.setHorizontalAlignment(SwingConstants.CENTER);    jLabel2.setText("学号:");    jLabel2.setBounds(new Rectangle(64, 89, 92, 25));    jLabel3.setBounds(new Rectangle(65, 141, 92, 25));    jLabel3.setText("密码:");    jLabel3.setHorizontalAlignment(SwingConstants.CENTER);    jLabel3.setForeground(Color.red);    jLabel3.setFont(new java.awt.Font("Serif", 1, 16));    jTextField1.setFont(new java.awt.Font("Serif", 0, 16));    jTextField1.setText("");    jTextField1.setBounds(new Rectangle(146, 89, 161, 25));    jPasswordField1.setFont(new java.awt.Font("Dialog", 0, 16));    jPasswordField1.setText("");    jPasswordField1.setBounds(new Rectangle(147, 139, 163, 26));    jButton1.setBounds(new Rectangle(79, 196, 73, 25));    jButton1.setFont(new java.awt.Font("Serif", 0, 12));    jButton1.setForeground(Color.red);    jButton1.setText("确定");    jButton1.addActionListener(new LoginDialog_jButton1_actionAdapter(this));    jButton2.setBounds(new Rectangle(254, 196, 73, 25));    jButton2.setFont(new java.awt.Font("Serif", 0, 12));    jButton2.setForeground(Color.orange);    jButton2.setText("重设");    jButton2.addActionListener(new LoginDialog_jButton2_actionAdapter(this));    getContentPane().add(panel1);    panel1.add(jLabel1, null);    panel1.add(jLabel2, null);    panel1.add(jTextField1, null);    panel1.add(jPasswordField1, null);    panel1.add(jLabel3, null);    panel1.add(jButton1, null);    panel1.add(jButton2, null);    con = connect.getconn();  }  void jButton1_actionPerformed(ActionEvent e) {    try {      con=connect.getconn();      stmt=con.createStatement();      int stID=Integer.parseInt(jTextField1.getText().trim());      String passwordtemp=jPasswordField1.getText();      String loginQuery="select * from StudentInfo where StID=" +stID+" and StPWD = " +passwordtemp;      ResultSet rs = stmt.executeQuery(loginQuery);      if(rs.next()) {        JOptionPane.showMessageDialog(this,"登陆成功","信息提示",1);       // Frame1.StID=stID;         Frame1.login=true;         this.hide();        return;     }      else {     Frame1.login_false();     jTextField1.setText("学号或者密码错误。");}      }catch(SQLException ex){       System.out.print("系统或者输进数据错误!"+ex.toString());     }  }  void jButton2_actionPerformed(ActionEvent e) {    jTextField1.setText("");    jPasswordField1.setText("");  }}class LoginDialog_jButton1_actionAdapter implements java.awt.event.ActionListener {  LoginDialog adaptee;  LoginDialog_jButton1_actionAdapter(LoginDialog adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton1_actionPerformed(e);  }}class LoginDialog_jButton2_actionAdapter implements java.awt.event.ActionListener {  LoginDialog adaptee;  LoginDialog_jButton2_actionAdapter(LoginDialog adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton2_actionPerformed(e);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -