-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSignupThree.java
More file actions
295 lines (246 loc) · 10.4 KB
/
SignupThree.java
File metadata and controls
295 lines (246 loc) · 10.4 KB
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 bank.management.system;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Random;
public class SignupThree extends JFrame implements ActionListener {
JRadioButton r1, r2, r3, r4;
JCheckBox c1, c2, c3, c4, c5, c6, c7;
JButton submit, cancel;
String formNumber;
SignupThree(String formNumber) {
this.formNumber = formNumber;
setLayout(null);
setTitle("NEW ACCOUNT APPLICATION FORM - PAGE 3");
JLabel l1 = new JLabel("Page 3: Account Details");
l1.setFont(new Font("Raleway", Font.BOLD, 22));
l1.setBounds(280, 40, 400, 40);
add(l1);
// --- Account Type ---
JLabel type = new JLabel("Account Type");
type.setFont(new Font("Raleway", Font.BOLD, 22));
type.setBounds(100, 140, 200, 30);
add(type);
r1 = new JRadioButton("Saving Account");
r1.setFont(new Font("Raleway", Font.BOLD, 16));
r1.setBackground(Color.WHITE);
r1.setBounds(100, 180, 250, 20);
add(r1);
r2 = new JRadioButton("Fixed Deposit Account");
r2.setFont(new Font("Raleway", Font.BOLD, 16));
r2.setBackground(Color.WHITE);
r2.setBounds(350, 180, 250, 20);
add(r2);
r3 = new JRadioButton("Current Account");
r3.setFont(new Font("Raleway", Font.BOLD, 16));
r3.setBackground(Color.WHITE);
r3.setBounds(100, 220, 250, 20);
add(r3);
r4 = new JRadioButton("Recurring Deposit Account");
r4.setFont(new Font("Raleway", Font.BOLD, 16));
r4.setBackground(Color.WHITE);
r4.setBounds(350, 220, 250, 20);
add(r4);
ButtonGroup groupAccount = new ButtonGroup();
groupAccount.add(r1);
groupAccount.add(r2);
groupAccount.add(r3);
groupAccount.add(r4);
JLabel card = new JLabel("Card Number:");
card.setFont(new Font("Raleway", Font.BOLD, 22));
card.setBounds(100, 300, 200, 30);
add(card);
JLabel number = new JLabel("XXXX-XXXX-XXXX-4184");
number.setFont(new Font("Raleway", Font.BOLD, 22));
number.setBounds(330, 300, 300, 30);
add(number);
JLabel carddetail = new JLabel("Your 16 Digit Card Number");
carddetail.setFont(new Font("Raleway", Font.BOLD, 12));
carddetail.setBounds(100, 330, 300, 20);
add(carddetail);
JLabel pin = new JLabel("PIN:");
pin.setFont(new Font("Raleway", Font.BOLD, 22));
pin.setBounds(100, 370, 200, 30);
add(pin);
JLabel pnumber = new JLabel("XXXX");
pnumber.setFont(new Font("Raleway", Font.BOLD, 22));
pnumber.setBounds(330, 370, 300, 30);
add(pnumber);
JLabel pindetail = new JLabel("Your 4 Digit Password");
pindetail.setFont(new Font("Raleway", Font.BOLD, 12));
pindetail.setBounds(100, 400, 300, 20);
add(pindetail);
// --- Services Required ---
JLabel services = new JLabel("Services Required:");
services.setFont(new Font("Raleway", Font.BOLD, 22));
services.setBounds(100, 450, 400, 30);
add(services);
c1 = new JCheckBox("ATM CARD");
c1.setBackground(Color.WHITE);
c1.setFont(new Font("Raleway", Font.BOLD, 16));
c1.setBounds(100, 500, 200, 30);
add(c1);
c2 = new JCheckBox("Internet Banking");
c2.setBackground(Color.WHITE);
c2.setFont(new Font("Raleway", Font.BOLD, 16));
c2.setBounds(350, 500, 200, 30);
add(c2);
c3 = new JCheckBox("Mobile Banking");
c3.setBackground(Color.WHITE);
c3.setFont(new Font("Raleway", Font.BOLD, 16));
c3.setBounds(100, 550, 200, 30);
add(c3);
c4 = new JCheckBox("EMAIL & SMS Alerts");
c4.setBackground(Color.WHITE);
c4.setFont(new Font("Raleway", Font.BOLD, 16));
c4.setBounds(350, 550, 200, 30);
add(c4);
c5 = new JCheckBox("Cheque Book");
c5.setBackground(Color.WHITE);
c5.setFont(new Font("Raleway", Font.BOLD, 16));
c5.setBounds(100, 600, 200, 30);
add(c5);
c6 = new JCheckBox("E-Statement");
c6.setBackground(Color.WHITE);
c6.setFont(new Font("Raleway", Font.BOLD, 16));
c6.setBounds(350, 600, 200, 30);
add(c6);
// --- Declaration ---
c7 = new JCheckBox("I hereby declare that the above entered details are correct to the best of my knowledge.");
c7.setBackground(Color.WHITE);
c7.setFont(new Font("Raleway", Font.BOLD, 12));
c7.setBounds(100, 680, 600, 30);
add(c7);
// --- Animated Buttons ---
submit = createAnimatedButton("Submit", new Color(34, 139, 34)); // Green color
submit.setBounds(250, 720, 120, 40);
submit.addActionListener(this);
add(submit);
cancel = createAnimatedButton("Cancel", new Color(220, 20, 60)); // Red color
cancel.setBounds(420, 720, 120, 40);
cancel.addActionListener(this);
add(cancel);
// --- Frame Settings ---
getContentPane().setBackground(Color.WHITE);
setSize(850, 820);
setLocation(350, 0);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
// --- Helper method to create animated buttons ---
private JButton createAnimatedButton(String text, Color bgColor) {
JButton button = new JButton(text) {
private float scale = 1.0f;
private boolean isHovered = false;
private Timer animationTimer;
private final Color originalColor = bgColor;
private final Color hoverColor = bgColor.brighter();
{
setContentAreaFilled(false);
setBorderPainted(false);
setFocusPainted(false);
setForeground(Color.WHITE);
setFont(new Font("Raleway", Font.BOLD, 16));
setCursor(new Cursor(Cursor.HAND_CURSOR));
addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
isHovered = true;
startAnimation();
}
@Override
public void mouseExited(MouseEvent e) {
isHovered = false;
startAnimation();
}
});
}
private void startAnimation() {
if (animationTimer != null && animationTimer.isRunning()) {
animationTimer.stop();
}
animationTimer = new Timer(10, e -> {
float targetScale = isHovered ? 1.1f : 1.0f;
if (scale < targetScale) {
scale = Math.min(targetScale, scale + 0.02f);
} else if (scale > targetScale) {
scale = Math.max(targetScale, scale - 0.02f);
} else {
((Timer) e.getSource()).stop();
}
repaint();
});
animationTimer.start();
}
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g.create();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int w = getWidth();
int h = getHeight();
int scaledW = (int) (w * scale);
int scaledH = (int) (h * scale);
int x = (w - scaledW) / 2;
int y = (h - scaledH) / 2;
// Set color based on hover state
g2.setColor(isHovered ? hoverColor : originalColor);
g2.fillRoundRect(x, y, scaledW, scaledH, 20, 20);
// Draw text
super.paintComponent(g);
g2.dispose();
}
};
return button;
}
@Override
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == submit) {
String accountType = null;
if (r1.isSelected()) {
accountType = "Saving Account";
} else if (r2.isSelected()) {
accountType = "Fixed Deposit Account";
} else if (r3.isSelected()) {
accountType = "Current Account";
} else if (r4.isSelected()) {
accountType = "Recurring Deposit Account";
}
if (accountType == null) {
JOptionPane.showMessageDialog(null, "Account Type is Required");
return;
}
if (!c7.isSelected()) {
JOptionPane.showMessageDialog(null, "Please accept the declaration to proceed.");
return;
}
Random random = new Random();
String cardNumber = "" + Math.abs((random.nextLong() % 90000000L) + 5040936000000000L);
String pinNumber = "" + Math.abs((random.nextLong() % 9000L) + 1000L);
String facility = "";
if (c1.isSelected()) facility += " ATM Card";
if (c2.isSelected()) facility += " Internet Banking";
if (c3.isSelected()) facility += " Mobile Banking";
if (c4.isSelected()) facility += " EMAIL & SMS Alerts";
if (c5.isSelected()) facility += " Cheque Book";
if (c6.isSelected()) facility += " E-Statement";
try {
Conn conn = new Conn();
String query1 = "INSERT INTO signupthree VALUES('" + formNumber + "', '" + accountType + "', '" + cardNumber + "', '" + pinNumber + "', '" + facility + "')";
String query2 = "INSERT INTO login VALUES('" + formNumber + "', '" + cardNumber + "', '" + pinNumber + "')";
conn.s.executeUpdate(query1);
conn.s.executeUpdate(query2);
JOptionPane.showMessageDialog(null, "Card Number: " + cardNumber + "\nPIN: " + pinNumber);
setVisible(false);
new Deposit(pinNumber).setVisible(true);
} catch (Exception e) {
System.out.println(e);
}
} else if (ae.getSource() == cancel) {
setVisible(false);
new Login().setVisible(true);
}
}
public static void main(String[] args) {
new SignupThree("");
}
}