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

📄 passworframe.java

📁 图书管理系统源代码,05年某人写的,还算不错
💻 JAVA
字号:
package booksboeeowreadsystem;

import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;
import java.sql.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyAdapter;

/**
 * <p>Title: 图书借阅系统</p>
 *
 * <p>Description: 科学的管理系统</p>
 *
 * <p>Copyright: 吴明卫小组</p>
 *
 * <p>Company: </p>
 *
 * @author 吴明卫
 * @version 1.0
 */

public class PassworFrame extends JFrame {
    Dbcom db;
    ImageIcon login = new ImageIcon("../booksboeeowreadsystem/image/login.png");
    public PassworFrame(Dbcom db) {
        try {
            if(SystemFrame1.login!=null)
                jtName.setText(SystemFrame1.login);
            this.db = db;
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }
    JLabel jLabel1 = new JLabel();
   JLabel jLabel2 = new JLabel();
   JTextField jtName = new JTextField();
   JPasswordField jPasswordNew = new JPasswordField();
   JLabel jLabel3 = new JLabel();
   JButton btnExit = new JButton();
   JButton btnXiugai = new JButton();
   JLabel jButton3 = new JLabel(login);
   JPasswordField jPasswordNewQ = new JPasswordField();
   JLabel jLabel4 = new JLabel();
   JPasswordField jPasswordOld = new JPasswordField();
   JLabel jLabel6 = new JLabel();
   JButton btnReset = new JButton();

    private void jbInit() throws Exception {
        getContentPane().setLayout(null);
        this.setTitle("管理员登录界面");
        jLabel1.setFont(new java.awt.Font("Default", Font.PLAIN, 16));
        jLabel1.setForeground(Color.blue);
        jLabel1.setToolTipText("");
        jLabel1.setText("新  密  码");
        jLabel1.setBounds(new Rectangle(47, 139, 84, 34));
        jtName.setFont(new java.awt.Font("Default", Font.PLAIN, 16));
        jtName.setForeground(SystemColor.activeCaption);
        jtName.setBounds(new Rectangle(123, 72, 177, 28));
        jPasswordNew.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
        jPasswordNew.setForeground(Color.magenta);
        jPasswordNew.setBounds(new Rectangle(122, 140, 177, 28));

        jLabel3.setFont(new java.awt.Font("Default", Font.BOLD, 32));
        jLabel3.setForeground(Color.blue);
        jLabel3.setText("密码管理");
        jLabel3.setBounds(new Rectangle(43, 17, 198, 31));
        btnExit.setBounds(new Rectangle(234, 235, 75, 36));
        btnExit.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
        btnExit.setForeground(Color.blue);
        btnExit.setText("关闭");
        btnExit.addActionListener(new PassworFrame_btnExit_actionAdapter(this));

        btnXiugai.setBounds(new Rectangle(48, 235, 75, 36));
        btnXiugai.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
        btnXiugai.setForeground(Color.blue);
        btnXiugai.setText("修改");
        btnXiugai.addActionListener(new PassworFrame_btnXiugai_actionAdapter(this));

        jButton3.setBackground(SystemColor.control);
        jButton3.setBounds(new Rectangle(249, 12, 47, 39));
        jButton3.setBorder(null);
        jButton3.setDisabledIcon(login);
        jPasswordNewQ.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
        jPasswordNewQ.setForeground(Color.magenta);
        jPasswordNewQ.setText("");
        jPasswordNewQ.setBounds(new Rectangle(121, 178, 177, 28));
        jLabel4.setFont(new java.awt.Font("Default", Font.PLAIN, 16));
        jLabel4.setForeground(Color.blue);
        jLabel4.setToolTipText("");
        jLabel4.setText("确认密码");
        jLabel4.setBounds(new Rectangle(46, 177, 70, 34));
        jPasswordOld.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
        jPasswordOld.setForeground(Color.magenta);
        jPasswordOld.setText("");
        jPasswordOld.setBounds(new Rectangle(122, 107, 177, 28));
        jLabel6.setFont(new java.awt.Font("Default", Font.PLAIN, 16));
        jLabel6.setForeground(Color.blue);
        jLabel6.setToolTipText("");
        jLabel6.setText("旧  密  码");
        jLabel6.setBounds(new Rectangle(47, 106, 71, 34));
        btnReset.setBounds(new Rectangle(141, 235, 75, 36));
        btnReset.setFont(new java.awt.Font("Default", Font.PLAIN, 16));
        btnReset.setForeground(Color.blue);
        btnReset.setText("重置");
        btnReset.addActionListener(new PassworFrame_btnReset_actionAdapter(this));
        jtName.setFont(new java.awt.Font("Default", Font.PLAIN, 16));
        this.getContentPane().add(jButton3);
        this.getContentPane().add(jLabel2);
        this.getContentPane().add(jtName);
        this.getContentPane().add(jPasswordNew);
        this.getContentPane().add(jLabel1);
        this.getContentPane().add(jPasswordOld);
        this.getContentPane().add(jLabel6);
        this.getContentPane().add(jPasswordNewQ);
        this.getContentPane().add(jLabel4);
        this.getContentPane().add(btnReset);
        this.getContentPane().add(btnXiugai);
        this.getContentPane().add(btnExit);
        this.getContentPane().add(jLabel3);
        jLabel2.setFont(new java.awt.Font("Default", Font.PLAIN, 16));
        jLabel2.setForeground(Color.blue);
        jLabel2.setToolTipText("");
        jLabel2.setText("用  户  名");
        jLabel2.setBounds(new Rectangle(48, 69, 71, 34));
    }








    public void jButton1_actionPerformed(ActionEvent e) {
        jtName.setText("");
        jPasswordNew.setText("");
    }

    public void btnExit_actionPerformed(ActionEvent e) {
        this.dispose();
    }

    public void btnReset_actionPerformed(ActionEvent e) {
        jtName.setText("");
        jPasswordNew.setText("");
        jPasswordNewQ.setText("");
        jPasswordOld.setText("");
    }

    public void btnXiugai_actionPerformed(ActionEvent e) {

           String name = jtName.getText().trim();
           String passNew = new String(jPasswordNew.getPassword()).trim();
           String passNewQ = new String(jPasswordNewQ.getPassword()).trim();
           String passOld = new String(jPasswordOld.getPassword()).trim();
           if (name.length() > 0 && passOld.length() > 0) {
               String sql = "select * from quanxian where name='" + name +
                            "' and password='" + passOld + "'";
               //判断登录的密码和用户信息,成功登录如下
              ResultSet re = db.search(sql);
               try {
                   if (re.next()) {

                       //在数据库中获得权限的整型值

                      re.updateString("password",passNewQ);
                      re.updateRow();

                          JOptionPane.showMessageDialog(null, "修改成功", "成功",JOptionPane.QUESTION_MESSAGE);

                       this.dispose();
                   } else {
                       JOptionPane.showMessageDialog(null, "不存在的用户,或密码错误,\n请确认 用户名 密码 再次输入","失败",JOptionPane.ERROR_MESSAGE);
                   }
               } catch (SQLException ex) {
                   System.out.println(ex.toString() + "\n登录时出现异常");
               }
               db.myClose(1);
           } else
               JOptionPane.showMessageDialog(this, "资料没有填写完整,\n请丛重新填写完整", "警告",
                                             JOptionPane.WARNING_MESSAGE);

    }
}


class PassworFrame_btnXiugai_actionAdapter implements ActionListener {
    private PassworFrame adaptee;
    PassworFrame_btnXiugai_actionAdapter(PassworFrame adaptee) {
        this.adaptee = adaptee;
    }

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


class PassworFrame_btnReset_actionAdapter implements ActionListener {
    private PassworFrame adaptee;
    PassworFrame_btnReset_actionAdapter(PassworFrame adaptee) {
        this.adaptee = adaptee;
    }

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


class PassworFrame_btnExit_actionAdapter implements ActionListener {
    private PassworFrame adaptee;
    PassworFrame_btnExit_actionAdapter(PassworFrame adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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