?? changepassword.java~5~
字號(hào):
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,330);
jLabel1.setText("舊密碼");
jLabel1.setBounds(new Rectangle(46, 34, 83, 33));
jPasswordField_new2.setText("");
jPasswordField_new2.setBounds(new Rectangle(142, 168, 174, 40));
jLabel3.setText("確認(rèn)新密碼");
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 mysysuser set password='"+new1+"'")){
JOptionPane.showMessageDialog(null, "密碼修改成功", "密碼修改",
JOptionPane.INFORMATION_MESSAGE);
this.dispose();
}else{
JOptionPane.showMessageDialog(null, "新密碼不應(yīng)過長", "密碼修改",
JOptionPane.ERROR_MESSAGE);
}
}else{
JOptionPane.showMessageDialog(null, "新密碼不一致", "密碼修改",
JOptionPane.ERROR_MESSAGE);
return;
}
}else{
JOptionPane.showMessageDialog(null, "舊密碼錯(cuò)誤", "密碼修改",
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);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -