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

📄 findoutpassworddialog.java

📁 图书馆座位管理系统
💻 JAVA
字号:
package librarysearchingsystem;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import com.borland.jbcl.layout.XYLayout;
import fileUtility.StudentsManagement;


public class FindOutPasswordDialog extends JDialog implements ActionListener {
    private final int width = 324;
    private final int height = 160;
    static String tempPassword = "000000";
    static int serial;
    Frame f;
    public FindOutPasswordDialog(Frame f) {
        this.f = f;
        try {
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public FindOutPasswordDialog(int serial) {
        this.serial = serial;
        try {
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }


    private void jbInit() throws Exception {
        this.setSize(width, height);
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        this.setLocation((d.width - width) / 2, (d.height - height) / 2);

        jLabel1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 16));
        jLabel1.setForeground(SystemColor.inactiveCaption);
        jLabel1.setText("密码提示问题:");
        jLabel1.setBounds(new Rectangle(17, 15, 122, 23));
        this.getContentPane().setLayout(null);
        jLabel2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 16));
        jLabel2.setForeground(UIManager.getColor(
                "FormattedTextField.selectionBackground"));
        jLabel2.setText("答案");
        jLabel2.setBounds(new Rectangle(17, 51, 122, 23));
        noButton.setBounds(new Rectangle(196, 83, 69, 31));
        noButton.setFont(new java.awt.Font("隶书", Font.PLAIN, 16));
        noButton.setText("取消");
        yesButton.setBounds(new Rectangle(59, 83, 69, 31));

        yesButton.setFont(new java.awt.Font("隶书", Font.PLAIN, 16));
        yesButton.setText("确定");
        xYLayout1.setWidth(327);
        xYLayout1.setHeight(155);
        this.setResizable(false);
        this.setTitle("找回密码");
        this.getContentPane().add(answerTextField, null);
        questionTextField.setBounds(new Rectangle(165, 17, 143, 21));
        answerTextField.setBounds(new Rectangle(166, 52, 143, 21));
        this.getContentPane().add(jLabel1, null);
        this.getContentPane().add(jLabel2, null);
        this.getContentPane().add(noButton, null);
        this.getContentPane().add(questionTextField, null);
        this.getContentPane().add(yesButton, null);

        questionTextField.setText(StudentsManagement.students[serial].question);
        questionTextField.setEditable(false);

        answerTextField.addActionListener(this);
        yesButton.addActionListener(this);
        noButton.addActionListener(this);
        this.setModal(true);
        this.setVisible(true);
    }

    JLabel jLabel1 = new JLabel();
    XYLayout xYLayout1 = new XYLayout();
    JTextField questionTextField = new JTextField();
    JPasswordField answerTextField = new JPasswordField();
    JButton yesButton = new JButton();
    JButton noButton = new JButton();
    JLabel jLabel2 = new JLabel();
    public void actionPerformed(ActionEvent e) {
        this.dispose();
        if (e.getSource() != noButton) {

            if (check()) {
                StudentsManagement.students[serial].changePasswordTo(
                        tempPassword);
                new TipsDialog("您的密码已改为:" + tempPassword + ",请尽快修改", true);
            } else {
                new TipsDialog("密码提示答案错误");
            }
        }
    }

    /**
     * check
     */
    private boolean check() {
        char ch[] = answerTextField.getPassword();
//        System.out.println("1" + StudentsManagement.students[serial].answer +                           "1");
        return StudentsManagement.students[serial].answer.equals(String.valueOf(
                ch));
    }

    public static void main(String[] args) {
        new FindOutPasswordDialog(2);
    }

    /** @todo 未作事件部分 */
}

⌨️ 快捷键说明

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