-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResetMemberPasswordView.java
75 lines (54 loc) · 1.89 KB
/
ResetMemberPasswordView.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
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import Common.CreateMemberException;
public class ResetMemberPasswordView extends JFrame{
private Admin admin;
//private AdminController controller;
private JPanel panel;
private JButton submitButton, cancelButton;
private JLabel label0, label1;
private JTextField input0, input1;
private AdminView controller;
public ResetMemberPasswordView(AdminView controller){
this.controller=controller;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel = new JPanel();
label0 = new JLabel("Player name");
input0 = new JTextField();
label1 = new JLabel("Player new password");
input1 = new JTextField();
submitButton = new JButton("Submit");
submitButton.addActionListener(new SubmitButtonListener());
cancelButton = new JButton("Cancel");
cancelButton.addActionListener(new ButtonListener());
panel.add(label0);
panel.add(input0);
panel.add(label1);
panel.add(input1);
panel.add(submitButton);
panel.add(cancelButton);
panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));
panel.setBorder(BorderFactory.createTitledBorder("Reset Player Password"));
panel.setLayout(new GridLayout(3,2));
panel.setBackground(Color.white);
add(panel);
}
private class ButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
controller.mainMenu();
}
}
private class SubmitButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
String name = input0.getText();
String password = input1.getText();
try {
controller.resetPlayerPassword(name, password);
JOptionPane.showMessageDialog(panel, "Player password reset!","Information", JOptionPane.PLAIN_MESSAGE);
} catch (CreateMemberException e1) {
JOptionPane.showMessageDialog(panel, e1.getMessage(),"Information", JOptionPane.PLAIN_MESSAGE);
}
}
}
}