-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForgetPassword.java
193 lines (153 loc) · 5.57 KB
/
ForgetPassword.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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.sql.*;
import javax.swing.border.*;
import java.lang.*;
/**
*
* @author user
*/
public class ForgetPassword extends JFrame {
JLabel l1, l2, l3, l4, l5;
JTextField t1, t2, t3, t4, t5;
JButton search, retrive, back;
ForgetPassword() {
// setLocationRelativeTo(null);
setTitle("Forget Password");
setLayout(null);
setSize(500, 500);
setVisible(true);
setBounds(700, 300, 500, 500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel p = new JPanel();
TitledBorder title;
title = BorderFactory.createTitledBorder("Forget Password");
//BorderFactory.createTitledBorder(null, "text", TitledBorder.CENTER, TitledBorder.BOTTOM, new Font("times new roman",Font.PLAIN,12), Color.yellow)
title.setTitleColor(Color.RED);
title.setTitleFont(new Font("times new roman", Font.PLAIN, 20));
// title.setTitleJustification(TitledBorder.LEFT);
p.setBorder(title);
// p.setBackground();
p.setBounds(10, 20, 450, 300);
p.setLayout(null);
l1 = new JLabel("UserName");
l1.setBounds(10, 40, 100, 30);
p.add(l1);
l2 = new JLabel("Name");
l2.setBounds(10, 80, 100, 30);
p.add(l2);
l3 = new JLabel("Your Security Question");
l3.setBounds(10, 120, 200, 30);
p.add(l3);
l4 = new JLabel("Answer");
l4.setBounds(10, 160, 200, 30);
p.add(l4);
l5 = new JLabel("Your Password");
l5.setBounds(10, 200, 100, 30);
p.add(l5);
t1 = new JTextField();
t1.setBounds(180, 40, 150, 30);
p.add(t1);
t2 = new JTextField();
t2.setBounds(180, 80, 150, 30);
t2.setEditable(false);
p.add(t2);
t3 = new JTextField();
t3.setBounds(180, 120, 200, 30);
t3.setEditable(false);
p.add(t3);
t4 = new JTextField();
t4.setBounds(180, 160, 150, 30);
p.add(t4);
t5 = new JTextField();
t5.setBounds(180, 200, 150, 30);
p.add(t5);
search = new JButton("Search");
search.setBounds(340, 40, 100, 30);
search.setIcon(new ImageIcon(getClass().getResource("/8.png")));
search.setHorizontalAlignment(SwingConstants.LEFT);
search.setBackground(new Color(240, 126, 86));
p.add(search);
search.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
search();
}
});
retrive = new JButton("Retrive");
retrive.setBounds(340, 160, 100, 30);
retrive.setIcon(new ImageIcon(getClass().getResource("/bg5.jpg")));
retrive.setHorizontalAlignment(SwingConstants.LEFT);
p.add(retrive);
retrive.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
retrive();
}
});
add(p);
back = new JButton("Back");
back.setSize(100, 100);
back.setIcon(new ImageIcon(getClass().getResource("/11.png")));
back.setHorizontalAlignment(SwingConstants.LEFT);
back.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
Login w = new Login();
try {
w.LoginFrame();
} catch (Exception ev) {
}
}
});
back.setBounds(200, 400, 100, 30);
add(back);
repaint();
}
void search() {
String a1 = t1.getText();
String sql = "select name,question from sign where username='" + a1 + "'";
JavaConnection dm = new JavaConnection();
dm.connection();
ResultSet rs = dm.executeQuery(sql);
try {
// System.out.println("username:" + rs.getString(1) + " password " + rs.getString(2));
if (rs.next()) {
t2.setText(rs.getString(1));
t3.setText(rs.getString(2));
} else {
JOptionPane.showMessageDialog(null, "User Not Exists ");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
void retrive() {
String user = t1.getText();
String a1 = t4.getText();
String sql = "select password from sign where answer='" + a1 + "' And username='" + user + "'";
JavaConnection dm = new JavaConnection();
dm.connection();
ResultSet rs = dm.executeQuery(sql);
try {
// System.out.println("username:" + rs.getString(1) + " password " + rs.getString(2));
if (rs.next()) {
t5.setText(rs.getString(1));
t5.setEditable(false);
} else {
JOptionPane.showMessageDialog(null, "your Answer is Wrong ");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
}
class forget {
public static void main(String[] args) {
ForgetPassword s = new ForgetPassword();
}
}