-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI_RecuperacaoPass.java
More file actions
194 lines (166 loc) · 6.55 KB
/
GUI_RecuperacaoPass.java
File metadata and controls
194 lines (166 loc) · 6.55 KB
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
194
/**
*Text genereted by Simple GUI Extension for BlueJ
*/
import javax.swing.UIManager.LookAndFeelInfo;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import javax.swing.border.Border;
import javax.swing.*;
public class GUI_RecuperacaoPass extends JFrame {
/** Variáveis de Instância. */
private JMenuBar menuBar;
private JButton ButtonPasswordRecover;
private JTextField TextFNif;
private JLabel label1;
private JLabel label2;
private JLabel label3;
private JLabel label4;
private String email;
private String nif;
private GestaoFichas gestorfichas;
/** Construtor parametrizado da classe GUI_RecuperacaoPass.
* @param gestorfichas gestorfichas passado da classe interface.
*/
public GUI_RecuperacaoPass(GestaoFichas gestorfichas){
this.gestorfichas = gestorfichas;
this.setTitle("GUI_RecuperacaoPass");
this.setSize(600,270);
//menu generate method
generateMenu();
this.setJMenuBar(menuBar);
//pane with null layout
JPanel contentPane = new JPanel(null);
contentPane.setPreferredSize(new Dimension(600,270));
contentPane.setBackground(new Color(192,192,192));
ButtonPasswordRecover = new JButton();
ButtonPasswordRecover.setBounds(210,134,160,35);
ButtonPasswordRecover.setBackground(new Color(214,217,223));
ButtonPasswordRecover.setForeground(new Color(0,0,0));
ButtonPasswordRecover.setEnabled(true);
ButtonPasswordRecover.setFont(new Font("sansserif",0,12));
ButtonPasswordRecover.setText("Recuperar Password");
ButtonPasswordRecover.setVisible(true);
//Set methods for mouse events
//Call defined methods
ButtonPasswordRecover.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
OnButtonPassRecoverClicked(evt);
}
});
TextFNif = new JTextField();
TextFNif.setBounds(92,133,90,35);
TextFNif.setBackground(new Color(255,255,255));
TextFNif.setForeground(new Color(0,0,0));
TextFNif.setEnabled(true);
TextFNif.setFont(new Font("sansserif",0,12));
TextFNif.setText("");
TextFNif.setVisible(true);
//Set action for key events
//Call defined method
TextFNif.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent evt){
onTextFNifKeyReleased(evt);
}
});
label1 = new JLabel();
label1.setBounds(107,29,400,35);
label1.setBackground(new Color(214,217,223));
label1.setForeground(new Color(0,0,0));
label1.setEnabled(true);
label1.setFont(new Font("SansSerif",0,30));
label1.setText("Recuperacao de Password");
label1.setVisible(true);
label2 = new JLabel();
label2.setBounds(40,92,400,35);
label2.setBackground(new Color(214,217,223));
label2.setForeground(new Color(0,0,0));
label2.setEnabled(true);
label2.setFont(new Font("sansserif",0,12));
label2.setText("Insira o seu email para tentarmos recuperar a sua password:");
label2.setVisible(true);
label3 = new JLabel();
label3.setBounds(60,136,90,35);
label3.setBackground(new Color(214,217,223));
label3.setForeground(new Color(0,0,0));
label3.setEnabled(true);
label3.setFont(new Font("sansserif",0,12));
label3.setText("Nif:");
label3.setVisible(true);
label4 = new JLabel();
label4.setBounds(44,175,500,50);
label4.setBackground(new Color(214,217,223));
label4.setForeground(new Color(0,204,0));
label4.setEnabled(true);
label4.setFont(new Font("sansserif",0,12));
label4.setText("<html>Enviamos um mail para o seu correio eletrónico <br/> que contem os dados referentes a sua conta </html>");
label4.setVisible(false);
//adding components to contentPane panel
contentPane.add(ButtonPasswordRecover);
contentPane.add(TextFNif);
contentPane.add(label1);
contentPane.add(label2);
contentPane.add(label3);
contentPane.add(label4);
//adding panel to JFrame and seting of window position and close operation
this.add(contentPane);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setLocationRelativeTo(null);
this.pack();
this.setVisible(true);
}
//Method mouseClicked for ButtonPasswordRecover
private void OnButtonPassRecoverClicked (MouseEvent evt) {
FichaCliente foundficha = gestorfichas.getFicha(Integer.parseInt(nif));
if(foundficha == null){
JOptionPane.showMessageDialog(null,"Nif nao registado!", "Message", JOptionPane.ERROR_MESSAGE);
}
else{
new SendMail(foundficha);
JOptionPane.showMessageDialog(null,"Enviamos um mail para o seu Email com os dados referentes a sua conta!", "Message" , JOptionPane.INFORMATION_MESSAGE);
label4.setVisible(true);
}
}
/** Metodo que define o email do cliente
* @param evt Evento da Acao
*/
private void onTextFNifKeyReleased (KeyEvent evt) {
nif = TextFNif.getText();
}
/** Metodo que cria um toolBar
*/
public void generateMenu(){
menuBar = new JMenuBar();
JMenu file = new JMenu("File");
JMenu tools = new JMenu("Tools");
JMenu help = new JMenu("Help");
JMenuItem open = new JMenuItem("Open ");
JMenuItem save = new JMenuItem("Save ");
JMenuItem exit = new JMenuItem("Exit ");
JMenuItem preferences = new JMenuItem("Preferences ");
JMenuItem about = new JMenuItem("About ");
file.add(open);
file.add(save);
file.addSeparator();
file.add(exit);
tools.add(preferences);
help.add(about);
menuBar.add(file);
menuBar.add(tools);
menuBar.add(help);
}
public static void main(String[] args){
System.setProperty("swing.defaultlaf", "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
new GUI_RecuperacaoPass(null);
}
});
}
}