-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRegistration.java
executable file
·117 lines (101 loc) · 3.11 KB
/
Registration.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
package se115.master;
import javax.swing.*;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedWriter;
import java.io.FileWriter;
public class Registration {
private JFrame frame = new JFrame("IUE");
private String nameSurname = "null";
private String number = "00000000000";
private String department = "null";
private JPanel content;
private boolean isDone = true;
/**
* Getter and Setter methods
*/
public boolean isDone() {
return isDone;
}
public void setDone(boolean done) {
isDone = done;
}
public String getNameSurname() {
return nameSurname;
}
public String getNumber() {
return number;
}
public String getDepartment() {
return department;
}
/**
* Adding panel with next page button
*/
public void setContent() {
content = new JPanel();
content.setLayout(null);
content.setBorder(new TitledBorder(new LineBorder(Color.MAGENTA,5), ""));
JButton saveBtn = new JButton("Save Information");
saveBtn.setBounds(50,35,200,100);
saveBtn.addActionListener(new SaveBtnListener());
content.add(saveBtn);
}
/**
* Getting information from user
*/
public void inputNameSurname() {
nameSurname = JOptionPane.showInputDialog(null,"Name and Surname","Info"
, JOptionPane.QUESTION_MESSAGE);
}
public void inputNumber() {
number = JOptionPane.showInputDialog(null,"School Number","Info"
, JOptionPane.QUESTION_MESSAGE);
}
public void inputDepartment() {
department = JOptionPane.showInputDialog(null,"Department","Info"
, JOptionPane.QUESTION_MESSAGE);
}
/**
* Creating a frame that contains next button
*/
public void setRegisterFrame() {
frame.setTitle("IEU");
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
frame.setSize(300,200);
frame.setLocationRelativeTo(null);
frame.add(content);
frame.setResizable(false);
frame.setVisible(true);
}
/**
* write information to users.txt file
*/
private void setDataBase() {
String fullInfo = nameSurname + "/" + number + "/" + department;
try {
FileWriter fileWriter = new FileWriter("users.txt");
BufferedWriter writer = new BufferedWriter(fileWriter);
writer.write(fullInfo);
writer.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
/**
* Inner class which provides actionPerformed method for Save Information button
*/
private class SaveBtnListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
frame.setVisible(false);
setDataBase();
MainPanel main = new MainPanel();
main.setFrame();
main.setInfo(nameSurname, number, department);
}
}
}