-
Notifications
You must be signed in to change notification settings - Fork 5
/
ForgotPassword.java
169 lines (135 loc) · 4.73 KB
/
ForgotPassword.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
package travel_and_Tourism_Organisation_System;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import java.sql.*;
import java.awt.event.*;
public class ForgotPassword extends JFrame implements ActionListener{
private JPanel contentPane;
private JTextField t1,t2,t3,t4,t5;
private JButton b1,b2,b3;
public static void main(String[] args) {
new ForgotPassword().setVisible(true);
}
public ForgotPassword() {
setBounds(300,200, 850, 400);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setBackground(Color.WHITE);
contentPane.setLayout(null);
JLabel l1 = new JLabel("Username");
l1.setFont(new Font("Tahoma", Font.BOLD, 13));
l1.setBounds(109, 83, 87, 29);
contentPane.add(l1);
JLabel l2 = new JLabel("Name");
l2.setFont(new Font("Tahoma", Font.BOLD, 13));
l2.setBounds(109, 122, 75, 21);
contentPane.add(l2);
JLabel l3 = new JLabel("Your Security Question");
l3.setFont(new Font("Tahoma", Font.BOLD, 13));
l3.setBounds(109, 154, 156, 27);
contentPane.add(l3);
JLabel l4 = new JLabel("Answer");
l4.setFont(new Font("Tahoma", Font.BOLD, 13));
l4.setBounds(109, 192, 104, 21);
contentPane.add(l4);
JLabel l5 = new JLabel("Password");
l5.setFont(new Font("Tahoma", Font.BOLD, 13));
l5.setBounds(109, 224, 104, 21);
contentPane.add(l5);
t1 = new JTextField();
t1.setFont(new Font("Tahoma", Font.BOLD, 13));
t1.setForeground(new Color(105, 105, 105));
t1.setBounds(277, 88, 139, 20);
contentPane.add(t1);
t1.setColumns(10);
t2 = new JTextField();
t2.setEditable(false);
t2.setFont(new Font("Tahoma", Font.BOLD, 13));
t2.setForeground(new Color(165, 42, 42));
t2.setColumns(10);
t2.setBounds(277, 123, 139, 20);
contentPane.add(t2);
t3 = new JTextField();
t3.setEditable(false);
t3.setFont(new Font("Tahoma", Font.BOLD, 12));
t3.setForeground(new Color(72, 61, 139));
t3.setColumns(10);
t3.setBounds(277, 161, 221, 20);
contentPane.add(t3);
t4 = new JTextField();
t4.setFont(new Font("Tahoma", Font.BOLD, 13));
t4.setForeground(new Color(205, 92, 92));
t4.setColumns(10);
t4.setBounds(277, 193, 139, 20);
contentPane.add(t4);
t5 = new JTextField();
t5.setEditable(false);
t5.setFont(new Font("Tahoma", Font.BOLD, 13));
t5.setForeground(new Color(50, 205, 50));
t5.setColumns(10);
t5.setBounds(277, 225, 139, 20);
contentPane.add(t5);
ImageIcon c1 = new ImageIcon(ClassLoader.getSystemResource("travel_and_Tourism_Organisation_System/icons/forgotpassword.jpg"));
Image i1 = c1.getImage().getScaledInstance(200, 200,Image.SCALE_DEFAULT);
ImageIcon i2 = new ImageIcon(i1);
JLabel l6 = new JLabel(i2);
l6.setBounds(590, 80, 200, 200);
add(l6);
b1 = new JButton("Search");
b1.addActionListener(this);
b1.setFont(new Font("Tahoma", Font.BOLD, 12));
b1.setBounds(428, 83, 80, 29);
b1.setBackground(Color.BLACK);
b1.setForeground(Color.WHITE);
contentPane.add(b1);
b2 = new JButton("Retrieve");
b2.addActionListener(this);
b2.setFont(new Font("Tahoma", Font.BOLD, 12));
b2.setBounds(426, 188, 85, 29);
b2.setBackground(Color.BLACK);
b2.setForeground(Color.WHITE);
contentPane.add(b2);
b3 = new JButton("Back");
b3.addActionListener(this);
b3.setFont(new Font("Tahoma", Font.BOLD, 13));
b3.setBounds(233, 270, 101, 29);
b3.setBackground(Color.BLACK);
b3.setForeground(Color.WHITE);
contentPane.add(b3);
JPanel panel = new JPanel();
panel.setBounds(47, 45, 508, 281);
panel.setBackground(new Color(255,204,204));
contentPane.add(panel);
}
public void actionPerformed(ActionEvent ae){
try{
Conn con = new Conn();
if(ae.getSource() == b1){
String sql = "select * from account where username=?";
PreparedStatement st = con.c.prepareStatement(sql);
st.setString(1, t1.getText());
ResultSet rs = st.executeQuery();
while (rs.next()) {
t2.setText(rs.getString("name"));
t3.setText(rs.getString("security"));
}
}
if(ae.getSource() == b2){
String sql = "select * from account where answer=?";
PreparedStatement st = con.c.prepareStatement(sql);
st.setString(1, t4.getText());
ResultSet rs = st.executeQuery();
while (rs.next()) {
t5.setText(rs.getString("password"));
}
}
if(ae.getSource() == b3){
this.setVisible(false);
new Login().setVisible(true);
}
}catch(Exception e){
}
}
}