-
Notifications
You must be signed in to change notification settings - Fork 0
/
MakeTransfers.java
295 lines (235 loc) · 9.02 KB
/
MakeTransfers.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
package ATM;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
import java.awt.Font;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JTextField;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.awt.event.ActionEvent;
import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.border.LineBorder;
public class MakeTransfers extends JFrame {
Deposit obj3 = new Deposit();
private JPanel contentPane;
private JTextField textField_2;
private JTextField textField_4;
boolean activiator ;
boolean activiator1 ;
String CurrentBalanceMT;
Deposit Obj4 = new Deposit();
private JTextField textField;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MakeTransfers frame = new MakeTransfers();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public MakeTransfers(){
Initialize_Mt();
}
/**
* Create the frame.
*
*/
public void WriteBackWD(){
FileWriter fwTM;
try{
fwTM = new FileWriter(new File("C:\\Users\\Kings\\Documents\\AccountInformation.txt"));
for (int i = 0; i < 5; i++){
if(i == 3){
fwTM.write(GetCurrentBL());
fwTM.write(System.lineSeparator());
i++;
}
fwTM.write(Obj4.array[i]);
fwTM.write(System.lineSeparator());
}
fwTM.close();
}
catch(IOException ex){
System.out.println("wht");
}
}
public String GetCurrentBL(){
return CurrentBalanceMT;
}
public void SetCurrentBL(String oldBalance){
this.CurrentBalanceMT = oldBalance;
}
public void Initialize_Mt() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 602, 616);
contentPane = new JPanel();
contentPane.setForeground(new Color(255, 255, 255));
contentPane.setBackground(Color.WHITE);
contentPane.setBorder(new LineBorder(new Color(255, 0, 0)));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblWelcomeToAcount = new JLabel("Welcome To Acount Transfer Section");
lblWelcomeToAcount.setFont(new Font("Tahoma", Font.BOLD, 21));
lblWelcomeToAcount.setBounds(96, 137, 412, 44);
contentPane.add(lblWelcomeToAcount);
JLabel lblFrom = new JLabel("Move From :");
lblFrom.setFont(new Font("Tahoma", Font.BOLD, 17));
lblFrom.setBounds(15, 197, 136, 20);
contentPane.add(lblFrom);
JRadioButton rdbtnChecking = new JRadioButton("CHECKING");
rdbtnChecking.setBackground(new Color(255, 255, 255));
rdbtnChecking.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
activiator = true;
}
});
rdbtnChecking.setFont(new Font("Tahoma", Font.PLAIN, 14));
rdbtnChecking.setBounds(72, 229, 155, 29);
contentPane.add(rdbtnChecking);
JRadioButton rdbtnSavings = new JRadioButton("SAVINGS");
rdbtnSavings.setBackground(new Color(255, 255, 255));
rdbtnSavings.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null,"you do not have a savings account","Important Message",JOptionPane.PLAIN_MESSAGE);
activiator = false;
}
});
rdbtnSavings.setFont(new Font("Tahoma", Font.PLAIN, 14));
rdbtnSavings.setBounds(72, 275, 155, 29);
contentPane.add(rdbtnSavings);
JLabel lblMoveTo = new JLabel("Move To :");
lblMoveTo.setFont(new Font("Tahoma", Font.BOLD, 17));
lblMoveTo.setBounds(15, 326, 136, 20);
contentPane.add(lblMoveTo);
JRadioButton rdbtnChecking_1 = new JRadioButton("CHECKING");
rdbtnChecking_1.setBackground(new Color(255, 255, 255));
rdbtnChecking_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
activiator1 = true;
}
});
rdbtnChecking_1.setFont(new Font("Tahoma", Font.PLAIN, 14));
rdbtnChecking_1.setBounds(72, 358, 155, 29);
contentPane.add(rdbtnChecking_1);
JRadioButton rdbtnSavings_1 = new JRadioButton("SAVINGS");
rdbtnSavings_1.setBackground(new Color(255, 255, 255));
rdbtnSavings_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
activiator1 = false;
JOptionPane.showMessageDialog(null,"you do not have a savings account","Important Message",JOptionPane.PLAIN_MESSAGE);
}
});
rdbtnSavings_1.setFont(new Font("Tahoma", Font.PLAIN, 14));
rdbtnSavings_1.setBounds(72, 395, 155, 29);
contentPane.add(rdbtnSavings_1);
JRadioButton rdbtnAcountNumber = new JRadioButton("ACOUNT NUMBER ");
rdbtnAcountNumber.setBackground(new Color(255, 255, 255));
rdbtnAcountNumber.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
activiator1 = true;
}
});
rdbtnAcountNumber.setFont(new Font("Tahoma", Font.PLAIN, 14));
rdbtnAcountNumber.setBounds(72, 432, 155, 32);
contentPane.add(rdbtnAcountNumber);
JButton btnTransfer = new JButton("TRANSFER");
btnTransfer.setFont(new Font("Tahoma", Font.BOLD, 17));
btnTransfer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if((activiator == true) && (activiator1 = true)){
int userInput = Integer.parseInt(textField_2.getText());
int withdrawAm = Obj4.getBalanceNum()- userInput;
String withdrawAm1 = Integer.toString(withdrawAm);
SetCurrentBL(withdrawAm1);
WriteBackWD();
}
else{
JOptionPane.showMessageDialog(null,"you have made an invalied selection","Important Message",JOptionPane.PLAIN_MESSAGE);
}
}
});
btnTransfer.setBounds(449, 432, 131, 31);
contentPane.add(btnTransfer);
ButtonGroup group = new ButtonGroup();
ButtonGroup group1 = new ButtonGroup();
group.add(rdbtnChecking );
group.add(rdbtnSavings);
group1.add(rdbtnChecking_1);
group1.add(rdbtnSavings_1);
group1.add(rdbtnAcountNumber);
textField_2 = new JTextField();
textField_2.setBorder(new LineBorder(new Color(255, 0, 0)));
textField_2.setBounds(291, 435, 146, 26);
contentPane.add(textField_2);
textField_2.setColumns(10);
textField_4 = new JTextField();
textField_4.setBorder(new LineBorder(new Color(255, 0, 0)));
textField_4.setEditable(false);
textField_4.setText("0.00");
textField_4.setText(obj3.array[3]);
textField_4.setBounds(430, 206, 146, 26);
contentPane.add(textField_4);
textField_4.setColumns(10);
JLabel lblCurrentBalance = new JLabel("Current Balance");
lblCurrentBalance.setFont(new Font("Tahoma", Font.BOLD, 17));
lblCurrentBalance.setBounds(420, 181, 145, 20);
contentPane.add(lblCurrentBalance);
JLabel lblTransferAccount = new JLabel("Transfer Account");
lblTransferAccount.setFont(new Font("Tahoma", Font.BOLD, 17));
lblTransferAccount.setBounds(281, 394, 161, 29);
contentPane.add(lblTransferAccount);
textField = new JTextField();
textField.setBorder(new LineBorder(new Color(255, 0, 0)));
textField.setBounds(426, 276, 146, 26);
String Temp = Integer.toString(Obj4.getAcountNum());
textField.setText(Temp);
contentPane.add(textField);
textField.setColumns(10);
JLabel lblAccountNumber = new JLabel("Account Number");
lblAccountNumber.setFont(new Font("Tahoma", Font.BOLD, 17));
lblAccountNumber.setBounds(420, 250, 155, 23);
contentPane.add(lblAccountNumber);
JLabel label = new JLabel("$");
label.setForeground(new Color(0, 128, 0));
label.setFont(new Font("Tahoma", Font.BOLD, 18));
label.setBounds(271, 436, 20, 23);
contentPane.add(label);
JLabel label_1 = new JLabel("$");
label_1.setForeground(new Color(0, 128, 0));
label_1.setFont(new Font("Tahoma", Font.BOLD, 19));
label_1.setBounds(399, 197, 29, 37);
contentPane.add(label_1);
JLabel lblNewLabel = new JLabel("");
lblNewLabel.setIcon(new ImageIcon("C:\\Users\\kings\\Downloads\\uh.jpg"));
lblNewLabel.setBounds(96, 0, 385, 72);
contentPane.add(lblNewLabel);
JButton btnNewButton = new JButton("COUGAR ATM");
btnNewButton.setBorder(new LineBorder(new Color(255, 0, 0)));
btnNewButton.setOpaque(false);
btnNewButton.setBackground(new Color(0, 0, 0));
btnNewButton.setFont(new Font("Tahoma", Font.BOLD, 20));
btnNewButton.setBounds(174, 70, 230, 44);
contentPane.add(btnNewButton);
JButton btnNewButton_1 = new JButton("");
btnNewButton_1.setBackground(new Color(0, 0, 0));
btnNewButton_1.setBounds(0, 502, 580, 58);
contentPane.add(btnNewButton_1);
}
}