-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPin.java
145 lines (116 loc) · 4.35 KB
/
Pin.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
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package bankmanagement;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
/**
*
* @author cotad
*/
public class Pin extends JFrame implements ActionListener {
JButton b1,b2;
JPasswordField p1,p2;
String pin;
Pin(String pin){
this.pin =pin;
ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("iconn/atm2.png"));
java.awt.Image i2 = i1.getImage().getScaledInstance(1550,830,java.awt.Image.SCALE_DEFAULT);
ImageIcon i3 = new ImageIcon(i2);
JLabel l3 = new JLabel(i3);
l3.setBounds(0,0,1550,830);
add(l3);
JLabel label1 = new JLabel("CHANGE YOUR PIN");
label1.setForeground(Color.WHITE);
label1.setFont(new Font("System", Font.BOLD, 16));
label1.setBounds(430,180,400,35);
l3.add(label1);
JLabel label2 = new JLabel("New PIN: ");
label2.setForeground(Color.WHITE);
label2.setFont(new Font("System", Font.BOLD, 16));
label2.setBounds(430,220,150,35);
l3.add(label2);
p1 = new JPasswordField();
p1.setBackground(new Color(65,125,128));
p1.setForeground(Color.WHITE);
p1.setBounds(600,220,180,25);
p1.setFont(new Font("Raleway", Font.BOLD,22));
l3.add(p1);
JLabel label3 = new JLabel("Re-Enter New PIN: ");
label3.setForeground(Color.WHITE);
label3.setFont(new Font("System", Font.BOLD, 16));
label3.setBounds(430,250,400,35);
l3.add(label3);
p2 = new JPasswordField();
p2.setBackground(new Color(65,125,128));
p2.setForeground(Color.WHITE);
p2.setBounds(600,255,180,25);
p2.setFont(new Font("Raleway", Font.BOLD,22));
l3.add(p2);
b1 = new JButton("CHANGE");
b1.setBounds(700,362,150,35);
b1.setBackground(new Color(65,125,128));
b1.setForeground(Color.WHITE);
b1.addActionListener(this);
l3.add(b1);
b2 = new JButton("BACK");
b2.setBounds(700,406,150,35);
b2.setBackground(new Color(65,125,128));
b2.setForeground(Color.WHITE);
b2.addActionListener(this);
l3.add(b2);
setSize(1550,1080);
setLayout(null);
setLocation(0,0);
setVisible(true);
}0
@Override
public void actionPerformed(ActionEvent e) {
try{
String pin1 = p1.getText();
String pin2 = p2.getText();
if (!pin1.equals(pin2)){
JOptionPane.showMessageDialog(null,"Entered PIN does not match");
return;
}
if (e.getSource()==b1){
if (p1.getText().equals("")){
JOptionPane.showMessageDialog(null,"Enter New PIN");
return;
}
if (p2.getText().equals("")){
JOptionPane.showMessageDialog(null,"Re-Enter New PIN");
return;
}
connn c = new connn();
String q1 = "update bank set pin = '"+pin1+"' where pin = '"+pin+"'";
String q2 = "update loginn set pin = '"+pin1+"' where pin = '"+pin+"'";
String q3 = "update signupthree set pin = '"+pin1+"' where pin = '"+pin+"'";
c.statement.executeUpdate(q1);
c.statement.executeUpdate(q2);
c.statement.executeUpdate(q3);
JOptionPane.showMessageDialog(null,"PIN changed successfully");
setVisible(false);
new main_Class(pin);
} else if (e.getSource()==b2) {
new main_Class(pin);
setVisible(false);
}
}catch (Exception E){
E.printStackTrace();
}
mj
}
public static void main(String[] args) {
new Pin("");
}
}