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

📄 userlogin.java~1~

📁 虚拟的图书管理系统
💻 JAVA~1~
字号:
package bookmanager;import java.awt.*;import javax.swing.*;import com.borland.jbcl.layout.*;import java.awt.event.*;import java.sql.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class userLogin extends JDialog {  ResultSet rs;    //定义结果集  private DBManager db =new DBManager();//定义数据库操作对象BookManagerMain myMain;  //定义主窗口类,用于操作父窗体  JPanel panel1 = new JPanel();  XYLayout xYLayout1 = new XYLayout();  XYLayout xYLayout2 = new XYLayout();  JLabel jLabel1 = new JLabel();  JLabel jLabel2 = new JLabel();  JTextField jTextFieldusername = new JTextField();  JButton jButtonOK = new JButton();  JButton jButtonCancel = new JButton();  JPasswordField jPasswordold = new JPasswordField();    //缺省构造方法  public userLogin(Frame frame, String title, boolean modal) {    super(frame, title, modal);    try {      jbInit();      pack();    }    catch(Exception ex) {      ex.printStackTrace();    }  }    //缺省构造方法  public userLogin() {    this(null, "", false);  }   //定义可传递父类的构造方法  public userLogin(BookManagerMain  bMain) {    this(null, "", false);    myMain=bMain ;  }  //初始化对象  private void jbInit() throws Exception {    panel1.setLayout(xYLayout2);    this.getContentPane().setLayout(xYLayout1);    jLabel1.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel1.setText("用户名");    jLabel2.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel2.setText("密码");    jTextFieldusername.setFont(new java.awt.Font("Dialog", 0, 16));    jTextFieldusername.setText("");    jButtonOK.setFont(new java.awt.Font("Dialog", 0, 16));    jButtonOK.setText("确定");    jButtonOK.addMouseListener(new userLogin_jButtonOK_mouseAdapter(this));    jButtonCancel.setFont(new java.awt.Font("Dialog", 0, 16));    jButtonCancel.setText("取消");    jButtonCancel.addMouseListener(new userLogin_jButtonCancel_mouseAdapter(this));    jPasswordold.setText("");    xYLayout1.setWidth(400);    xYLayout1.setHeight(271);    getContentPane().add(panel1,    new XYConstraints(0, 0, 400, 258));    panel1.add(jTextFieldusername,  new XYConstraints(210, 49, 111, 38));    panel1.add(jPasswordold, new XYConstraints(211, 112, 111, 35));    panel1.add(jLabel1,  new XYConstraints(59, 50, 99, 34));    panel1.add(jLabel2,  new XYConstraints(60, 116, 80, 34));    panel1.add(jButtonCancel,   new XYConstraints(212, 209, 94, 30));    panel1.add(jButtonOK, new XYConstraints(94, 208, 91, 31));  }  void jButtonCancel_mouseClicked(MouseEvent e) {          this.dispose();  }  void jButtonOK_mouseClicked(MouseEvent e) {         if(jTextFieldusername.getText().trim() =="")             { JOptionPane.showMessageDialog(null,"用户名不可为空!");                  return;}         if(jPasswordold.getText().trim() =="")             {JOptionPane.showMessageDialog(null,"密码不可为空!");                 return;}        String strSQL ;        strSQL="select * from user where username='"+jTextFieldusername.getText().trim() +"' and password='"+jPasswordold.getText().trim()+"'";               rs=db.getResult(strSQL) ;        if(rs.equals(null ))          {JOptionPane.showMessageDialog(null,"用户名不存在,或密码不正确!");             myMain.setEnable(false);          }        else          {  myMain.setEnable(true); }  }}class userLogin_jButtonCancel_mouseAdapter extends java.awt.event.MouseAdapter {  userLogin adaptee;  userLogin_jButtonCancel_mouseAdapter(userLogin adaptee) {    this.adaptee = adaptee;  }  public void mouseClicked(MouseEvent e) {    adaptee.jButtonCancel_mouseClicked(e);  }}class userLogin_jButtonOK_mouseAdapter extends java.awt.event.MouseAdapter {  userLogin adaptee;  userLogin_jButtonOK_mouseAdapter(userLogin adaptee) {    this.adaptee = adaptee;  }  public void mouseClicked(MouseEvent e) {    adaptee.jButtonOK_mouseClicked(e);  }}

⌨️ 快捷键说明

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