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

📄 userupdate.java~1~

📁 虚拟的图书管理系统
💻 JAVA~1~
字号:
package bookmanager;import javax.swing.*;import com.borland.jbcl.layout.*;import java.awt.*;import java.sql.*;import java.awt.event.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class userUpdate extends JFrame {  ResultSet rs;    //定义结果集  private DBManager db =new DBManager();//定义数据库操作对象  XYLayout xYLayout1 = new XYLayout();  JButton jButtonCancel = new JButton();  JLabel jLabel2 = new JLabel();  JButton jButtonOK = new JButton();  JPasswordField jPasswordold = new JPasswordField();  JLabel jLabel1 = new JLabel();  JTextField jTextFieldusername = new JTextField();  JPasswordField jPasswordnew = new JPasswordField();  JLabel jLabel3 = new JLabel();  public userUpdate() {    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  public static void main(String[] args) {    userUpdate userUpdate = new userUpdate();  }  private void jbInit() throws Exception {    jTextFieldusername.setText("");    jTextFieldusername.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel1.setText("用户名");    jLabel1.setFont(new java.awt.Font("Dialog", 0, 16));    jPasswordold.setText("");    jButtonOK.setText("更新");    jButtonOK.addMouseListener(new userUpdate_jButtonOK_mouseAdapter(this));    jButtonOK.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel2.setText("原密码");    jLabel2.setFont(new java.awt.Font("Dialog", 0, 16));     jButtonCancel.setText("取消");    jButtonCancel.addMouseListener(new userUpdate_jButtonCancel_mouseAdapter(this));    jButtonCancel.setFont(new java.awt.Font("Dialog", 0, 16));    this.getContentPane().setLayout(xYLayout1);    xYLayout1.setWidth(400);    xYLayout1.setHeight(312);    jLabel3.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel3.setText("新密码");    jPasswordnew.setFont(new java.awt.Font("Dialog", 0, 16));    jPasswordnew.setText("");    this.getContentPane().add(jTextFieldusername,  new XYConstraints(216, 35, 111, 38));    this.getContentPane().add(jLabel2, new XYConstraints(66, 102, 80, 34));    this.getContentPane().add(jPasswordold, new XYConstraints(217, 98, 111, 35));    this.getContentPane().add(jLabel1, new XYConstraints(65, 36, 99, 34));    this.getContentPane().add(jButtonCancel, new XYConstraints(209, 258, 94, 30));    this.getContentPane().add(jButtonOK, new XYConstraints(91, 257, 91, 31));    this.getContentPane().add(jPasswordnew,  new XYConstraints(216, 151, 114, 31));    this.getContentPane().add(jLabel3,  new XYConstraints(69, 160, 62, 30));  }  void jButtonCancel_mouseClicked(MouseEvent e) {             this.dispose();  }  void jButtonOK_mouseClicked(MouseEvent e) {       String strSQL ;           strSQL="select * from user where username='"+jTextFieldusername.getText().trim() +"' and password='"+jPasswordold.getText().trim()+"'";                  rs=db.getResult(strSQL) ;           if(rs.equals(null ))             {JOptionPane.showMessageDialog(null,"用户名不存在,或原密码不正确!");                      }           else             {              if(!jPasswordold.getText().trim().equals(jPasswordnew.getText().trim()))               {JOptionPane.showMessageDialog(null,"两次输入的密码不一致!");                return;                }               else               {                 strSQL="update user set password='"+jPasswordnew.getText().trim()+"' where username='"+jTextFieldusername.getText().trim() +"'";                 if(db.executeSql(strSQL))                    {JOptionPane.showMessageDialog(null,"成功更新!"); }                 else                    { JOptionPane.showMessageDialog(null," 更新失败,请重新操作!");      }               }             }  }}class userUpdate_jButtonCancel_mouseAdapter extends java.awt.event.MouseAdapter {  userUpdate adaptee;  userUpdate_jButtonCancel_mouseAdapter(userUpdate adaptee) {    this.adaptee = adaptee;  }  public void mouseClicked(MouseEvent e) {    adaptee.jButtonCancel_mouseClicked(e);  }}class userUpdate_jButtonOK_mouseAdapter extends java.awt.event.MouseAdapter {  userUpdate adaptee;  userUpdate_jButtonOK_mouseAdapter(userUpdate adaptee) {    this.adaptee = adaptee;  }  public void mouseClicked(MouseEvent e) {    adaptee.jButtonOK_mouseClicked(e);  }}

⌨️ 快捷键说明

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