-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChangePassword.java
175 lines (141 loc) · 5.04 KB
/
ChangePassword.java
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package ATM;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Font;
import javax.swing.ImageIcon;
import java.awt.Color;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
import javax.swing.UIManager;
import javax.swing.border.MatteBorder;
public class ChangePassword extends JFrame {
private JPanel contentPane;
private JTextField textField;
private JTextField textField_1;
private JTextField textField_2;
String CurrentPassword;
firstLayer Obj2 = new firstLayer();
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ChangePassword frame = new ChangePassword();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public ChangePassword(){
Initialize_ChPassword();
}
/**
* Create the frame.
*/
public void WriteBackCP(){
FileWriter fwCP;
String AccNum = Integer.toString(Obj2.AccountNum);
try{
fwCP= new FileWriter(new File("C:\\Users\\Kings\\Documents\\password.txt"));
fwCP.write(AccNum);
fwCP.write("\t");
fwCP.write(GetCurrentPW());
fwCP.close();
}
catch(IOException ex){
System.out.println("wht");
}
}
public String GetCurrentPW(){
return CurrentPassword;
}
public void SetCurrentPW(String oldpassword){
this.CurrentPassword = oldpassword;
}
public void Initialize_ChPassword() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 602, 616);
contentPane = new JPanel();
contentPane.setBackground(Color.WHITE);
contentPane.setBorder(new LineBorder(new Color(255, 0, 0)));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblWelcomeToChange = new JLabel("Welcome To Change Password Section");
lblWelcomeToChange.setFont(new Font("Tahoma", Font.BOLD, 21));
lblWelcomeToChange.setBounds(76, 151, 419, 27);
contentPane.add(lblWelcomeToChange);
JLabel lblAccount = new JLabel("Account Number:");
lblAccount.setFont(new Font("Tahoma", Font.BOLD, 20));
lblAccount.setBounds(43, 220, 212, 27);
contentPane.add(lblAccount);
JLabel lblNewLabel = new JLabel("Current Password :");
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 20));
lblNewLabel.setBounds(43, 283, 212, 27);
contentPane.add(lblNewLabel);
JLabel lblNewPassord = new JLabel("New Password :");
lblNewPassord.setFont(new Font("Tahoma", Font.BOLD, 20));
lblNewPassord.setBounds(43, 345, 184, 27);
contentPane.add(lblNewPassord);
textField = new JTextField();
textField.setBorder(new LineBorder(Color.RED));
textField.setBounds(283, 222, 212, 27);
contentPane.add(textField);
textField.setColumns(10);
textField_1 = new JTextField();
textField_1.setBorder(new LineBorder(Color.RED));
textField_1.setBounds(283, 285, 212, 26);
contentPane.add(textField_1);
textField_1.setColumns(10);
textField_2 = new JTextField();
textField_2.setBorder(new LineBorder(Color.RED, 1, true));
textField_2.setBounds(283, 347, 212, 26);
contentPane.add(textField_2);
textField_2.setColumns(10);
JButton btnChangePassword = new JButton("Change password");
btnChangePassword.setFont(new Font("Tahoma", Font.BOLD, 20));
btnChangePassword.addActionListener(new ActionListener() {
String AccNum1 = Integer.toString(Obj2.AccountNum);
public void actionPerformed(ActionEvent e) {
if(((textField.getText()).equals(AccNum1)) && (Obj2.password.equals(textField_1.getText()))){
SetCurrentPW(textField_2.getText());
WriteBackCP();
}
}
});
btnChangePassword.setBounds(321, 411, 212, 43);
contentPane.add(btnChangePassword);
JLabel lblNewLabel_1 = new JLabel("");
lblNewLabel_1.setIcon(new ImageIcon("C:\\Users\\kings\\Downloads\\uh.jpg"));
lblNewLabel_1.setBounds(91, 16, 385, 66);
contentPane.add(lblNewLabel_1);
JButton btnNewButton = new JButton("COUAGR ATM");
btnNewButton.setForeground(Color.RED);
btnNewButton.setBackground(Color.WHITE);
btnNewButton.setFont(new Font("Tahoma", Font.BOLD, 21));
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
}
});
btnNewButton.setBounds(168, 80, 212, 55);
contentPane.add(btnNewButton);
JButton btnNewButton_1 = new JButton("");
btnNewButton_1.setBackground(new Color(0, 0, 0));
btnNewButton_1.setBounds(0, 494, 580, 66);
contentPane.add(btnNewButton_1);
}
}