?? userupdate.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; //定義結(jié)果集 private DBManager db =new DBManager();//定義數(shù)據(jù)庫操作對象 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 + -