?? modifypassword.java
字號:
package com.csbook.restaurant;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import com.csbook.restaurant.utility.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author pengtao
* @version 1.0
*/
public class ModifyPassword extends JDialog {
JPanel panel1 = new JPanel();
GridLayout gridLayout1 = new GridLayout(3,2);
JLabel jLabel1 = new JLabel();
JPasswordField newPass2 = new JPasswordField();
JLabel jLabel2 = new JLabel();
JPasswordField newPass1 = new JPasswordField();
JLabel jLabel3 = new JLabel();
JPasswordField oriPass = new JPasswordField();
JPanel jPanel1 = new JPanel();
JLabel jLabel4 = new JLabel();
JPanel jPanel2 = new JPanel();
JButton ok = new JButton();
CheckUser cUser=new CheckUser();
public ModifyPassword(Frame frame, String title, boolean modal) {
super(frame, title, modal);
try {
jbInit();
pack();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
public ModifyPassword() {
this(null, "", false);
}
private void jbInit() throws Exception {
panel1.setLayout(gridLayout1);
jLabel1.setText("原密碼:");
jLabel2.setText("確認(rèn)新密碼:");
jLabel3.setText("新密碼:");
jLabel4.setText("修改密碼");
ok.setActionCommand("jButton1");
ok.setText("確定");
ok.addActionListener(new ModifyPassword_ok_actionAdapter(this));
oriPass.setText("");
newPass1.setText("");
getContentPane().add(panel1, BorderLayout.CENTER);
panel1.add(jLabel1, null);
panel1.add(oriPass, null);
panel1.add(jLabel3, null);
panel1.add(newPass1, null);
panel1.add(jLabel2, null);
panel1.add(newPass2, null);
this.getContentPane().add(jPanel1, BorderLayout.NORTH);
jPanel1.add(jLabel4, null);
this.getContentPane().add(jPanel2, BorderLayout.SOUTH);
jPanel2.add(ok, null);
}
void ok_actionPerformed(ActionEvent e) {
char temp[]=oriPass.getPassword();
String tempPass=new String(temp);
char temp1[]=newPass1.getPassword();
String pass1=new String(temp1);
char temp2[]=newPass2.getPassword();
String pass2=new String(temp2);
if(tempPass.trim().equals("")||pass1.trim().equals("")||pass2.trim().equals(""))
{
JOptionPane.showMessageDialog(this, "請輸入完整的信息", "錯誤",
JOptionPane.WARNING_MESSAGE);
return;
}
MainFrame k=(MainFrame)this.getOwner();
String operator=k.getOperator();
if(!cUser.isValidUser(operator,tempPass))
JOptionPane.showMessageDialog(this,"錯誤的用戶名或密碼","錯誤",JOptionPane.WARNING_MESSAGE);
else{
if(!pass1.equals(pass2))
JOptionPane.showMessageDialog(this,"兩次輸入的新密碼不一致","錯誤",JOptionPane.WARNING_MESSAGE);
else{
cUser.updatePassword(operator,pass1);
this.dispose();
JOptionPane.showMessageDialog(this,"密碼已成功修改","提示",JOptionPane.WARNING_MESSAGE);
}
}
}
}
class ModifyPassword_ok_actionAdapter implements java.awt.event.ActionListener {
ModifyPassword adaptee;
ModifyPassword_ok_actionAdapter(ModifyPassword adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.ok_actionPerformed(e);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -