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

📄 logindialog.java~8~

📁 网吧计费系统 通过程序实现网吧计费系统的过程
💻 JAVA~8~
字号:
package com.jbaptech.accp.netbar.client;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import com.jbaptech.accp.netbar.server.entity.Card;
import com.jbaptech.accp.netbar.server.action.BusinessAction;

/**
 *
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: 北京阿博泰克北大青鸟信息技术有限公司</p>
 *
 * @author luohao
 * @version 1.0
 */
public class LoginDialog extends JDialog{
   JPanel panel1 = new JPanel();
   JLabel cardIdLabel = new JLabel();
   JTextField cardIdTextField = new JTextField();
   JLabel passwordLabel = new JLabel();
   JButton confirmButton = new JButton();
   JButton resetButton = new JButton();
   JLabel welcomeLabel = new JLabel();
   JPasswordField passwordField = new JPasswordField();
   BorderLayout borderLayout1 = new BorderLayout();

   public LoginDialog(NetBarFeeMangementFrame frame, String title, boolean modal) {
     super(frame, title, modal);
     mainFrame = frame;
     this.setLocation(250,200);
     try {
       jbInit();
       pack();
     }
     catch(Exception ex) {
       ex.printStackTrace();
     }
   }

   public LoginDialog() {
     this(null, "", false);
   }
   private void jbInit() throws Exception {
     panel1.setLayout(null);
     this.getContentPane().setLayout(borderLayout1);

     panel1.setPreferredSize(new Dimension(300, 200));
     panel1.setRequestFocusEnabled(true);

     welcomeLabel.setFont(new java.awt.Font("Serif", 1, 16));
     welcomeLabel.setForeground(Color.blue);
     welcomeLabel.setHorizontalAlignment(SwingConstants.CENTER);
     welcomeLabel.setText("欢迎查询,请输卡号、密码");
     welcomeLabel.setBounds(new Rectangle(0, 10, 300, 30));

     cardIdLabel.setFont(new java.awt.Font("Serif", 1, 13));
     cardIdLabel.setHorizontalAlignment(SwingConstants.CENTER);
     cardIdLabel.setText("卡号:");
     cardIdLabel.setBounds(new Rectangle(80, 60, 45, 25));

     cardIdTextField.setText("111111");
     cardIdTextField.setBounds(new Rectangle(125, 60, 95, 25));

     passwordLabel.setFont(new java.awt.Font("Serif", 1, 13));
     passwordLabel.setText("密码:");
     passwordLabel.setBounds(new Rectangle(80, 110, 45, 25));

     passwordField.setText("111");
     passwordField.setBounds(new Rectangle(125, 110, 95, 25));

     confirmButton.setBounds(new Rectangle(75, 150, 60, 25));
     confirmButton.setText("确定");
     confirmButton.addActionListener(new LoginDialog_confirmButton_actionAdapter(this));
     resetButton.setBounds(new Rectangle(165, 150, 60, 25));
     resetButton.setText("重置");
     resetButton.addActionListener(new LoginDialog_resetButton_actionAdapter(this));

     getContentPane().add(panel1, BorderLayout.CENTER);
     panel1.add(passwordLabel, null);
     panel1.add(welcomeLabel, null);
     panel1.add(passwordField, null);
     panel1.add(cardIdTextField, null);
     panel1.add(cardIdLabel, null);
     panel1.add(confirmButton, null);
     panel1.add(resetButton, null);

    // con = barConnect.getconn();
   }

   void resetButton_actionPerformed(ActionEvent e) {
     cardIdTextField.setText("");
     passwordField.setText("");
   }

   void confirmButton_actionPerformed(ActionEvent e) {

     String cardId = cardIdTextField.getText().trim();
     String password = "";
     for(int i=0;i<passwordField.getPassword().length;i++)
        {
          password += passwordField.getPassword()[i];
        }
        Card card = new Card();
        card.setId(cardId);
        card.setPassword(password);



          if(BusinessAction.cardIsValid(card)){
            mainFrame.login_true();
           mainFrame.SetCardId(Integer.parseInt(cardId));
           this.hide();
           return;
          }else{
            cardIdTextField.setText("卡号或者密码不对。");
    }
     }

   protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      mainFrame.login_false();
      this.hide();
    }
  }

   //private Connection con;
   private NetBarFeeMangementFrame mainFrame;
   //private Statement stmt;
 }

 class LoginDialog_resetButton_actionAdapter implements java.awt.event.ActionListener {
   LoginDialog adaptee;

   LoginDialog_resetButton_actionAdapter(LoginDialog adaptee) {
     this.adaptee = adaptee;
   }
   public void actionPerformed(ActionEvent e) {
     adaptee.resetButton_actionPerformed(e);
   }
 }

 class LoginDialog_confirmButton_actionAdapter implements java.awt.event.ActionListener {
   LoginDialog adaptee;

   LoginDialog_confirmButton_actionAdapter(LoginDialog adaptee) {
     this.adaptee = adaptee;
   }
   public void actionPerformed(ActionEvent e) {
     adaptee.confirmButton_actionPerformed(e);
  }
}

⌨️ 快捷键说明

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