package com.vci.client.logon.base;
|
|
import java.awt.Dimension;
|
import java.awt.Frame;
|
import java.awt.Rectangle;
|
import java.awt.Toolkit;
|
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowEvent;
|
|
import javax.swing.JButton;
|
import javax.swing.JLabel;
|
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentListener;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.common.objects.UserEntityObject;
|
import com.vci.client.framework.systemConfig.stafforgmanage.UserTablePanel;
|
import com.vci.client.ui.swing.KPasswordField;
|
|
|
public class ChangePasswordDialog extends BaseJDialog{
|
|
private static final long serialVersionUID = 1L;
|
private JLabel prePasswordLabel = new JLabel("登陆密码:");
|
private JLabel passwordLabel = new JLabel("新登陆密码:");
|
private JLabel confirmLabel = new JLabel("新登陆密码确认:");
|
private KPasswordField prePasswordText = new KPasswordField();
|
private KPasswordField passwordText = new KPasswordField();
|
private KPasswordField confirmText = new KPasswordField();
|
private JButton buttonOk = new JButton("保存");
|
private JButton buttonCancel = new JButton("取消");
|
private UserEntityObject userEntityObj = null;
|
public ChangePasswordDialog(){
|
super(LogonApplication.frame,null,true);
|
userEntityObj = LogonApplication.getUserEntityObject();
|
init();
|
}
|
public ChangePasswordDialog(Frame frame, boolean closeIsExistSystem,UserEntityObject userEntityObj){
|
super(frame, true);
|
this.userEntityObj = userEntityObj;
|
init();
|
LogonApplication.getUserEntityObject().setModules("修改密码");
|
|
if(closeIsExistSystem){
|
disableCancel();
|
}
|
}
|
public void init(){
|
prePasswordLabel.setPreferredSize(new Dimension(100,25));
|
prePasswordLabel.setBounds(new Rectangle(
|
20,20,100,25));
|
passwordLabel.setPreferredSize(new Dimension(100,25));
|
passwordLabel.setBounds(new Rectangle(
|
20,50,100,25));
|
confirmLabel.setPreferredSize(new Dimension(100,25));
|
confirmLabel.setBounds(new Rectangle(
|
20,80,100,25));
|
prePasswordText.setPreferredSize(new Dimension(121,25));
|
prePasswordText.setBounds(new Rectangle(
|
150,20,121,25));
|
passwordText.setPreferredSize(new Dimension(121,25));
|
passwordText.setBounds(new Rectangle(
|
150,50,121,25));
|
confirmText.setPreferredSize(new Dimension(121,25));
|
confirmText.setBounds(new Rectangle(
|
150,80,121,25));
|
confirmText.setEnabled(false);
|
passwordText.getDocument().addDocumentListener(new DocumentListener() {
|
|
public void removeUpdate(DocumentEvent e) {
|
// String passwordString = passwordText.getText();
|
// confirmText.setText("");
|
// if("".equals(passwordString)){
|
// confirmText.setEnabled(false);
|
// }else{
|
// confirmText.setEnabled(true);
|
// }
|
}
|
|
public void insertUpdate(DocumentEvent e) {
|
String passwordString = passwordText.getText();
|
confirmText.setText("");
|
if("".equals(passwordString)){
|
confirmText.setEnabled(false);
|
}else{
|
confirmText.setEnabled(true);
|
}
|
}
|
|
public void changedUpdate(DocumentEvent e) {
|
// String passwordString = passwordText.getText();
|
// confirmText.setText("");
|
// if("".equals(passwordString)){
|
// confirmText.setEnabled(false);
|
// }else{
|
// confirmText.setEnabled(true);
|
// }
|
}
|
|
});
|
buttonOk.setPreferredSize(new Dimension(90,25));
|
buttonOk.setBounds(new Rectangle(
|
40,115,90,25));
|
buttonCancel.setPreferredSize(new Dimension(90,25));
|
buttonCancel.setBounds(new Rectangle(
|
160,115,90,25));
|
this.setLayout(null);
|
this.setTitle("修改密码");
|
this.add(prePasswordLabel);
|
this.add(passwordLabel);
|
this.add(confirmLabel);
|
this.add(prePasswordText);
|
this.add(passwordText);
|
this.add(confirmText);
|
this.add(buttonOk);
|
this.add(buttonCancel);
|
buttonOk.addActionListener(new ChangePassworActionListener(this,"save",userEntityObj));
|
buttonCancel.addActionListener(new ChangePassworActionListener(this,"cancel",userEntityObj));
|
}
|
public String getConfirmText() {
|
return new String(confirmText.getPassword());
|
}
|
public String getPasswordText() {
|
return new String(passwordText.getPassword());
|
}
|
public String getPrePasswordText() {
|
return new String(prePasswordText.getPassword());
|
}
|
private void disableCancel(){
|
Dimension screenSize = Toolkit.getDefaultToolkit ().getScreenSize ();
|
Dimension dialogSize = getPreferredSize ();
|
dialogSize.height = 220;
|
dialogSize.width = 300;
|
this.setTitle("修改密码");
|
this.setSize (dialogSize);
|
this.setResizable(false);
|
this.buttonOk.setBounds(new Rectangle(100,150,90,25));
|
this.buttonCancel.setVisible(false);
|
this.setLocation ( (screenSize.width - dialogSize.width) / 2, (screenSize.height - dialogSize.height) / 2);
|
this.addWindowListener(new WindowAdapter(){
|
public void windowClosing(WindowEvent e) {
|
System.exit(0);
|
}
|
});
|
}
|
}
|