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

📄 login1dialog.java

📁 简单的学生管理系统。。用JBUILER和SQL2000。
💻 JAVA
字号:
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 Login1Dialog 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 Login1Dialog(mainFrame frame, String title, boolean modal) {    super(frame, title, modal);     Frame1=frame;    this.setLocation(309,239);    try {      jbInit();      pack();    }    catch(Exception ex) {      ex.printStackTrace();    }  }  public Login1Dialog() {    this(null, "", false);  }  private void jbInit() throws Exception {    panel1.setLayout(null);    jLabel1.setFont(new java.awt.Font("Serif", 1, 20));    jLabel1.setForeground(Color.red);    jLabel1.setHorizontalAlignment(SwingConstants.CENTER);    jLabel1.setText("请输入教师号、密码");    jLabel1.setBounds(new Rectangle(-1, 0, 401, 43));    jLabel2.setFont(new java.awt.Font("Serif", 1, 16));    jLabel2.setForeground(SystemColor.textHighlight);    jLabel2.setHorizontalAlignment(SwingConstants.CENTER);    jLabel2.setText("教师号:");    jLabel2.setBounds(new Rectangle(70, 69, 78, 24));    jLabel3.setBounds(new Rectangle(67, 117, 78, 24));    jLabel3.setText("密   码:");    jLabel3.setHorizontalAlignment(SwingConstants.CENTER);    jLabel3.setForeground(SystemColor.textHighlight);    jLabel3.setFont(new java.awt.Font("Serif", 1, 16));    jTextField1.setFont(new java.awt.Font("Serif", 0, 14));    jTextField1.setText("");    jTextField1.setBounds(new Rectangle(165, 68, 150, 25));    jPasswordField1.setText("");    jPasswordField1.setBounds(new Rectangle(165, 116, 150, 26));    jButton1.setBounds(new Rectangle(78, 176, 73, 25));    jButton1.setFont(new java.awt.Font("Serif", 0, 12));    jButton1.setForeground(Color.red);    jButton1.setText("确定");    jButton1.addActionListener(new Login1Dialog_jButton1_actionAdapter(this));    jButton2.setBounds(new Rectangle(255, 173, 73, 25));    jButton2.setFont(new java.awt.Font("Serif", 0, 12));    jButton2.setForeground(Color.orange);    jButton2.setText("重设");    jButton2.addActionListener(new Login1Dialog_jButton2_actionAdapter(this));    getContentPane().add(panel1);    panel1.add(jLabel1, null);    panel1.add(jPasswordField1, null);    panel1.add(jTextField1, null);    panel1.add(jLabel2, 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();    String teID=jTextField1.getText();    String passwordtemp=jPasswordField1.getText();    String loginQuery="select * from TeacherInfo where TeID=" +teID+" and TePWD = " +passwordtemp;    ResultSet rs = stmt.executeQuery(loginQuery);    if(rs.next()) {      Frame1.TeID=teID;      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 Login1Dialog_jButton1_actionAdapter implements java.awt.event.ActionListener {  Login1Dialog adaptee;  Login1Dialog_jButton1_actionAdapter(Login1Dialog adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton1_actionPerformed(e);  }}class Login1Dialog_jButton2_actionAdapter implements java.awt.event.ActionListener {  Login1Dialog adaptee;  Login1Dialog_jButton2_actionAdapter(Login1Dialog adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton2_actionPerformed(e);  }}

⌨️ 快捷键说明

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