-
Notifications
You must be signed in to change notification settings - Fork 2
/
ForgotPage.java
134 lines (119 loc) · 3.67 KB
/
ForgotPage.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
package First;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
/**
* A JFrame class for the GUI design and the method of reminding the password
* @author Ayşegül Sümeyye Kütük
* @version 3.18
*/
public class ForgotPage extends JFrame implements ActionListener
{
JPanel contentPane;
JPasswordField passField;
JTextField userField;
JButton resetButton,cancelButton;
String usrname;
JLabel lblShow;
/**
* ForgotPage class for the GUI design
* @param usrname user name
*/
public ForgotPage(String usrname)
{
super("Welcome To Movie Recommender");
this.usrname = usrname;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 30, 500, 600);
contentPane = new JPanel();
contentPane.setBackground(new Color(250,250,250));
contentPane.setForeground(new Color(0, 0, 0));
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
ImageIcon imageIcon = new ImageIcon("images.jpg");
JLabel icon = new JLabel();
icon.setBounds(50, 140, 500, 500);
icon.setIcon(imageIcon);
contentPane.add(icon);
JLabel lblCoi = new JLabel("Forgot Your Password?");
lblCoi.setForeground(Color.BLACK);
lblCoi.setFont(new Font("Calibri", Font.BOLD, 26));
lblCoi.setBounds(70, 11, 400, 51);
contentPane.add(lblCoi);
userField = new JTextField();
userField.setBounds(210, 80, 180, 26);
contentPane.add(userField);
JLabel lblUsername = new JLabel("Your secret answer:");
lblUsername.setForeground(Color.BLACK);
lblUsername.setBounds(70, 80, 150, 20);
contentPane.add(lblUsername);
JLabel lblPass = new JLabel("Your password is :");
lblPass.setForeground(Color.BLACK);
lblPass.setBounds(70,110,180,26);
contentPane.add(lblPass);
lblShow = new JLabel ("");
lblShow.setForeground(Color.BLACK);
lblShow.setBounds(210,110,180,26);
contentPane.add(lblShow);
resetButton = new JButton("Enter!");
resetButton.setBackground(new Color(153,217,234));
resetButton.setForeground(Color.BLACK);
resetButton.setBounds(230, 180, 160, 26);
contentPane.add(resetButton);
cancelButton = new JButton("Cancel");
cancelButton.setBackground(new Color(153,217,234));
cancelButton.setForeground(Color.BLACK);
cancelButton.setBounds(230, 210, 160, 26);
contentPane.add(cancelButton);
resetButton.addActionListener(this);
cancelButton.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent arg0)
{
User user;
if(resetButton == arg0.getSource())
{
user = Database.cmpAnswer(usrname);
String a= userField.getText();
System.out.println(user.getAnswer());
/**
* The conditional for the function of reminding the password after the user name is taken by the system
*/
if(user!=null)
{
if (user.getAnswer().equals(a))
{
System.out.println(user.password);
this.lblShow.setText(""+user.password);
}
else
{
lblShow.setText("You entered wrong answer!");
}
}
}
/**
*Cancel operation to get back to the login page
*/
else if(cancelButton == arg0.getSource())
{
Login login = new Login();
login.setVisible(true);
this.dispose();
}
}
}