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

📄 password.java

📁 本文是用JAVA语言编写的,直接下载就可以 不要解压密码
💻 JAVA
字号:
package com;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import com.borland.jbcl.layout.*;

import com.dbmanage.*;
import com.account.*;
import com.*;
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 PassWord  extends JFrame{
  JLabel jLabel1 = new JLabel();
  XYLayout xYLayout1 = new XYLayout();
  JLabel jLabel2 = new JLabel();
  JButton jButton1 = new JButton();
  JLabel jLabel3 = new JLabel();
  JTextField jTextField1 = new JTextField();
  JPasswordField jPasswordField1 = new JPasswordField();

 public  boolean flag;
  String managername;
  String managerpassword;
  String outPut="";
  ///////////////////
  public PassWord() {
    try {
      flag=false;
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  private void jbInit() throws Exception {
    jLabel1.setFont(new java.awt.Font("SansSerif", 1, 22));
    jLabel1.setDebugGraphicsOptions(0);
    jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
    jLabel1.setHorizontalTextPosition(SwingConstants.CENTER);
    jLabel1.setText("酒店管理员验证");
    this.getContentPane().setLayout(xYLayout1);
    this.getContentPane().setBackground(UIManager.getColor("Desktop.background"));
    this.setForeground(Color.black);
    jLabel2.setFont(new java.awt.Font("SansSerif", 1, 16));
    jLabel2.setForeground(Color.black);
    jLabel2.setMinimumSize(new Dimension(55, 16));
    jLabel2.setHorizontalAlignment(SwingConstants.CENTER);
    jLabel2.setText("姓名");
    jButton1.setFont(new java.awt.Font("SansSerif", 1, 16));
    jButton1.setForeground(Color.black);
    jButton1.setHorizontalAlignment(SwingConstants.CENTER);
    jButton1.setText("登录");
    jButton1.addActionListener(new PassWord_jButton1_actionAdapter(this));
    jLabel3.setFont(new java.awt.Font("SansSerif", 1, 16));
    jLabel3.setForeground(Color.black);
    jLabel3.setVerifyInputWhenFocusTarget(true);
    jLabel3.setHorizontalAlignment(SwingConstants.CENTER);
    jLabel3.setText("密码");
    jTextField1.setText("");
    jPasswordField1.setText("");
    xYLayout1.setWidth(484);
    xYLayout1.setHeight(354);
    this.getContentPane().add(jLabel1, new XYConstraints(150, 43, 250, 40));

    this.getContentPane().add(jTextField1,  new XYConstraints(170, 120, 120, 40));
    this.getContentPane().add(jPasswordField1, new XYConstraints(170, 180, 120, 40));

    this.getContentPane().add(jButton1,    new XYConstraints(243, 251, 100, 40));    this.getContentPane().add(jLabel2, new XYConstraints(108, 120, 90, 40));    this.getContentPane().add(jLabel3,   new XYConstraints(106, 181, 92, 40));

   this.setVisible(true);
   }

  void jButton1_actionPerformed(ActionEvent e) throws Exception{//验证

    String name=jTextField1.getText().toString();
   String password=jPasswordField1.getText().toString();
    if(!name.equals("")&&!password.equals("")){
      String queryString = "select * from HIMS_MANAGER"; //查询语句
      try {
           JDBCFile conn = new JDBCFile(); //得到一个对象
           //首先得到查询结果的信息
           ResultSet resultSet = conn.executeQuery(queryString);

           while (resultSet.next()) {
          managername=resultSet.getString("Name");
          managerpassword=resultSet.getString("PassWord");

          if( managername.equals(name)&&managerpassword.equals(password)){
              this.flag=true;
              this.show(false);
              HIMSMain HIMSMain1 = new HIMSMain();
              HIMSMain1.setSize(750, 560);
              HIMSMain1.show();
              break;
              }//end if
              else {
             jTextField1.setText("");
             jPasswordField1.setText("");
              }
           }//end while
         }catch (SQLException q) {
           System.out.println(q);
         }
          System.out.println("先:"+flag);

    }//end if
        else{//都为空值,显示错误信息
        JOptionPane.showMessageDialog(null,"请输入完整信息","管理员登陆",
                                      JOptionPane.PLAIN_MESSAGE);
          }
  }

  public boolean getflag(){
  return flag;
    }
}

class PassWord_jButton1_actionAdapter implements java.awt.event.ActionListener {
  PassWord adaptee;

  PassWord_jButton1_actionAdapter(PassWord adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
   try{
    adaptee.jButton1_actionPerformed(e);
  }catch(Exception ee){
       System.out.println(ee);
       }
}
}

⌨️ 快捷键说明

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