wangting
2024-12-26 fa261e8c1220b31af54e8167e4de9c3320b1af27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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);
            }
        });
    }
}