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

📄 userpsw.java~10~

📁 一个看上去不错的JAVA毕业设计作品
💻 JAVA~10~
字号:
package zcgl;

import java.awt.*;

import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import javax.swing.BorderFactory;
import java.sql.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class UserPsw extends JFrame {
    Connection con = null;
    Statement smt = null;
    ResultSet rs = null;
    public UserPsw() {
        try {
            jbInit();
            con = new DbCon().getConnection();
            smt = con.createStatement();
            rs = smt.executeQuery("select * from OPERATOR");
            if (rs.next()) {
                txtUser.setText(rs.getString(1));
                txtPass.setText(rs.getString(2).trim());
            }

        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(null);
        jPanel1.setBorder(BorderFactory.createEtchedBorder());
        jPanel1.setBounds(new Rectangle(52, 48, 289, 168));
        jPanel1.setLayout(null);
        jLabel2.setText("密码");
        jLabel2.setBounds(new Rectangle(34, 103, 37, 26));
        txtPass.setBounds(new Rectangle(78, 107, 131, 21));
        jButton1.setBounds(new Rectangle(70, 236, 98, 37));
        jButton1.setToolTipText("");
        jButton1.setText("修改");
        jButton1.addActionListener(new UserPsw_jButton1_actionAdapter(this));
        jButton2.setBounds(new Rectangle(226, 236, 95, 39));
        jButton2.setText("退出");
        jButton2.addActionListener(new UserPsw_jButton2_actionAdapter(this));
        this.getContentPane().add(jPanel1);
        txtUser.setBounds(new Rectangle(75, 53, 131, 20));
        jPanel1.add(jLabel1);
        jPanel1.add(txtUser);
        jPanel1.add(jLabel2);
        jPanel1.add(txtPass);
        this.getContentPane().add(jButton1);
        this.getContentPane().add(jButton2);
        jLabel1.setText("用户");
        jLabel1.setBounds(new Rectangle(36, 50, 107, 29));

    }

    JPanel jPanel1 = new JPanel();
    JLabel jLabel1 = new JLabel();
    JTextField txtUser = new JTextField();
    JLabel jLabel2 = new JLabel();
    JPasswordField txtPass = new JPasswordField();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    public void jButton1_actionPerformed(ActionEvent e) {
        con = new DbCon().getConnection();

        try {

             smt = con.createStatement();
            smt.executeUpdate("update OPERATOR set name='" + txtUser.getText()+"',pwd='"+txtPass.getText()+"'");
            JOptionPane.showMessageDialog(this, "成功修改!");
        } catch (SQLException ex) {
        }
    }

    public void jButton2_actionPerformed(ActionEvent e) {
         System.exit(0);
    }
}


class UserPsw_jButton2_actionAdapter implements ActionListener {
    private UserPsw adaptee;
    UserPsw_jButton2_actionAdapter(UserPsw adaptee) {
        this.adaptee = adaptee;
    }

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


class UserPsw_jButton1_actionAdapter implements ActionListener {
    private UserPsw adaptee;
    UserPsw_jButton1_actionAdapter(UserPsw adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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