-
Notifications
You must be signed in to change notification settings - Fork 0
/
Profile.java
116 lines (98 loc) · 3.86 KB
/
Profile.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
import java.io.IOException;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Profile extends BorderPane {
private Label name, surname, address, email, tel;
private TextField nField, surField, adField, emField, tField;
private Button enter, close;
public Profile(Stage window, User user) {
GridPane grid = new GridPane();
grid.setVgap(10);
grid.setHgap(10);
grid.setPadding(new Insets(25, 25, 25, 25));
name = new Label("Name : ");
nField = new TextField();
nField.setPromptText("Name");
grid.add(name, 0, 0);
grid.add(nField, 1, 0);
surname = new Label("Surname : ");
surField = new TextField();
surField.setPromptText("Surname");
grid.add(surname, 0, 1);
grid.add(surField, 1, 1);
address = new Label("Address : ");
adField = new TextField();
adField.setPromptText("Address");
grid.add(address, 0, 2);
grid.add(adField, 1, 2);
email = new Label("E-mail : ");
emField = new TextField();
emField.setPromptText("Email");
grid.add(email, 0, 3);
grid.add(emField, 1, 3);
tel = new Label("Tel : ");
tField = new TextField();
tField.setPromptText("Tel");
grid.add(tel, 0, 4);
grid.add(tField, 1, 4);
grid.setAlignment(Pos.CENTER);
enter = new Button("Enter");
enter.setOnAction(e -> {
if (!nField.getText().equals(null) && !(nField.getText().equals(user.getName()))) {
user.setName(nField.getText());
}
if (!surField.getText().equals(null) && !(surField.getText().equals(user.getSurname()))) {
user.setSurname(surField.getText());
}
if (!adField.getText().equals(null) && !(adField.getText().equals(user.getAddress()))) {
user.setAddress(adField.getText());
}
if (!emField.getText().equals(null) && !(emField.getText().equals(user.getEmail()))) {
user.setEmail(emField.getText());
}
if (!tField.getText().equals(null) && !(tField.getText().equals(user.getTel()))) {
user.setTel(tField.getText());
}
try {
AboutUser.updateUser(user);
} catch (ClassNotFoundException | IOException e1) {
e1.printStackTrace();
}
try {
window.setScene(new Scene(new Dashboard(window, user), 1280, 720));
} catch (ClassNotFoundException | IOException e1) {
e1.printStackTrace();
}
});
close = new Button("Close");
close.setOnAction(e -> {
try {
window.setScene(new Scene(new Dashboard(window, user), 1280, 720));
} catch (ClassNotFoundException | IOException e1) {
e1.printStackTrace();
}
});
window.setOnCloseRequest(e -> {
try {
window.setScene(new Scene(new Dashboard(window, user), 1280, 720));
} catch (ClassNotFoundException | IOException e1) {
e1.printStackTrace();
}
});
HBox btn = new HBox(10, enter,close);
btn.setAlignment(Pos.CENTER);
VBox vb = new VBox(15);
vb.getChildren().addAll(grid,btn);
vb.setAlignment(Pos.CENTER);
setCenter(vb);
}
}