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

📄 dlgenter.java

📁 用java实现的一个应用程序,源码非常完整,可以直接运行
💻 JAVA
字号:
package 毕业设计;

import java.awt.Dialog;
import java.awt.Frame;
import javax.swing.JOptionPane;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.*;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import java.awt.event.*;

public class dlgEnter extends Dialog {
    JPanel panel1 = new JPanel();
    JLabel lblId = new JLabel();
    JTextField txtId = new JTextField();
    JLabel lblPassword = new JLabel();
    JPasswordField pswPassword = new JPasswordField();
    JButton btnOK = new JButton();
    JButton btnExit = new JButton();
    JLabel lblMap = new JLabel(new ImageIcon("Map/0040.jpg"));
    public dlgEnter(Frame owner, String title, boolean modal) {
        super(owner, title, modal);
        try {
//            setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            jbInit();
            pack();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    public dlgEnter() {
        this(new Frame(), "dlgEnter", false);
    }

    private void jbInit() throws Exception {
        panel1.setLayout(null);
        setTitle("密码验证");
        lblId.setFont(new java.awt.Font("Dialog", Font.PLAIN, 18));
        lblId.setText("卡  号:");
        lblId.setBounds(new Rectangle(54, 49, 58, 37));
        txtId.setBackground(Color.white);
        txtId.setFont(new java.awt.Font("Dialog", Font.PLAIN, 18));
        txtId.setText("3");
        txtId.setBounds(new Rectangle(114, 50, 171, 35));
        lblPassword.setFont(new java.awt.Font("Dialog", Font.PLAIN, 18));
        lblPassword.setText("密  码:");
        lblPassword.setBounds(new Rectangle(55, 112, 59, 31));
        pswPassword.setBackground(Color.white);
        pswPassword.setFont(new java.awt.Font("Dialog", Font.PLAIN, 18));
        pswPassword.setText("3");
        pswPassword.setBounds(new Rectangle(113, 109, 174, 35));
        btnOK.setBackground(new Color(118, 184, 255));
        btnOK.setBounds(new Rectangle(90, 178, 80, 36));
        btnOK.setFont(new java.awt.Font("Dialog", Font.PLAIN, 18));
        btnOK.setText("确  定");
        btnOK.addActionListener(new dlgEnter_btnOK_actionAdapter(this));
        btnExit.setBackground(new Color(118, 184, 255));
        btnExit.setBounds(new Rectangle(203, 178, 82, 35));
        btnExit.setFont(new java.awt.Font("Dialog", Font.PLAIN, 18));
        btnExit.setText("退  出");
        btnExit.addActionListener(new dlgEnter_btnExit_actionAdapter(this));
        lblMap.setText("");
        lblMap.setBounds(new Rectangle(0, 0, 400, 300));
        add(panel1);
        panel1.add(lblId);
        panel1.add(txtId);
        panel1.add(lblPassword);
        panel1.add(pswPassword);
        panel1.add(btnOK);
        panel1.add(btnExit);
        panel1.add(lblMap);
        this.setResizable(false);
        addWindowListener(new close());
    }

    //*******************************显示窗口*******************************
     public void ShowEnter() {
         this.setSize(400, 300);
         Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
         Dimension dlgSize = this.getSize();
         if (dlgSize.height > screenSize.height) {
             dlgSize.height = screenSize.height;
         }
         if (dlgSize.width > screenSize.width) {
             dlgSize.width = screenSize.width;
         }
         this.setLocation((screenSize.width - dlgSize.width) / 2,
                          (screenSize.height - dlgSize.height) / 2);
         this.setModal(true);
         this.setVisible(true);
     }

    //***************************退出按钮事件***********************************
     public void btnExit_actionPerformed(ActionEvent e) {
         System.exit(0);
     }

    //****************************关闭事件**********************************
     private class close extends WindowAdapter {
         public void windowClosing(WindowEvent e) {
             System.exit(0);
         }
     }


    //*****************************确定按钮事件*********************************
     public void btnOK_actionPerformed(ActionEvent e) {
         UserConDB userDB = new UserConDB();
         String Id = txtId.getText();
         String Password = String.valueOf(pswPassword.getPassword());
         boolean pwd = userDB.VerifyPassword(Id, Password);
         if (pwd) {
             userDB.setIsUsing();
             userDB.UpdateIsUsing(Id);
             this.dispose();
         } else {
             JOptionPane.showMessageDialog(this, "帐号不存在或密码错误!", "提示",
                                           JOptionPane.ERROR_MESSAGE);
             txtId.setText("");
             pswPassword.setText("");
         }
         userDB.CloseUserDB();
     }
}


class dlgEnter_btnOK_actionAdapter implements ActionListener {
    private dlgEnter adaptee;
    dlgEnter_btnOK_actionAdapter(dlgEnter adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnOK_actionPerformed(e);
    }
}


class dlgEnter_btnExit_actionAdapter implements ActionListener {
    private dlgEnter adaptee;
    dlgEnter_btnExit_actionAdapter(dlgEnter adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnExit_actionPerformed(e);
    }
}

⌨️ 快捷键说明

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