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

📄 changepassword.java~2~

📁 使用JBuilder基于Oracle数据库的课程作业
💻 JAVA~2~
字号:
package StudentManageSystem.mainframeswing;

import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import StudentManageSystem.link.SQLRunner;

class ChangePassword extends JDialog {
    String id;
    public ChangePassword(String id) {
        try {
            this.id=id;
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        this.getContentPane().setLayout(null);
        this.setSize(400,300);
        jLabel1.setText("旧密码");
        jLabel1.setBounds(new Rectangle(46, 34, 83, 33));
        jPasswordField_new2.setText("");
        jPasswordField_new2.setBounds(new Rectangle(142, 168, 174, 40));
        jLabel3.setText("确认新密码");
        jLabel3.setBounds(new Rectangle(46, 173, 64, 25));
        jPasswordField_new1.setText("");
        jPasswordField_new1.setBounds(new Rectangle(142, 101, 174, 38));
        jLabel2.setText("新密码");
        jLabel2.setBounds(new Rectangle(46, 106, 78, 31));
        jButton2.addActionListener(new ChangePassword_jButton2_actionAdapter(this));
        jButton1.addActionListener(new ChangePassword_jButton1_actionAdapter(this));
        this.getContentPane().add(jPasswordField_new1);
        jButton2.setBounds(new Rectangle(220, 241, 87, 31));
        jButton2.setText("取消");
        jButton1.setBounds(new Rectangle(96, 241, 85, 31));
        jButton1.setText("确定");
        this.getContentPane().add(jPasswordField_old);
        this.getContentPane().add(jLabel1);
        this.getContentPane().add(jLabel2);
        this.getContentPane().add(jLabel3);
        this.getContentPane().add(jPasswordField_new2);
        this.getContentPane().add(jButton1);
        this.getContentPane().add(jButton2);
        jPasswordField_old.setText("");
        jPasswordField_old.setBounds(new Rectangle(142, 28, 173, 38));
        this.setResizable(false);
    }

    JLabel jLabel1 = new JLabel();
    JPasswordField jPasswordField_old = new JPasswordField();
    JLabel jLabel2 = new JLabel();
    JPasswordField jPasswordField_new1 = new JPasswordField();
    JLabel jLabel3 = new JLabel();
    JPasswordField jPasswordField_new2 = new JPasswordField();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    public void jButton2_actionPerformed(ActionEvent e) {
        this.dispose();
    }

    public void jButton1_actionPerformed(ActionEvent e) {
        String old=new String(jPasswordField_old.getPassword());
        if(old.equals(id)){
            String new1=new String(jPasswordField_new1.getPassword());
            String new2=new String(jPasswordField_new2.getPassword());
            if(new1.equals(new2)){
                if(SQLRunner.executSql("update musysuser set password='"+new1+"'")){
                    JOptionPane.showMessageDialog(null, "密码修改成功", "密码修改",
                                              JOptionPane.INFORMATION_MESSAGE);
                }else{
                    JOptionPane.showMessageDialog(null, "新密码不应过长", "密码修改",
                                              JOptionPane.ERROR_MESSAGE);
                }
            }else{
                JOptionPane.showMessageDialog(null, "新密码不一致", "密码修改",
                                              JOptionPane.ERROR_MESSAGE);
            return;

            }
        }else{
            JOptionPane.showMessageDialog(null, "旧密码错误", "密码修改",
                                              JOptionPane.ERROR_MESSAGE);
            return;
        }
    }

}


class ChangePassword_jButton1_actionAdapter implements ActionListener {
    private ChangePassword adaptee;
    ChangePassword_jButton1_actionAdapter(ChangePassword adaptee) {
        this.adaptee = adaptee;
    }

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


class ChangePassword_jButton2_actionAdapter implements ActionListener {
    private ChangePassword adaptee;
    ChangePassword_jButton2_actionAdapter(ChangePassword adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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