-
Notifications
You must be signed in to change notification settings - Fork 0
/
SubjectDetail.java
172 lines (129 loc) · 6.64 KB
/
SubjectDetail.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
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
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import java.io.IOException;
public class SubjectDetail extends BorderPane {
Text topicText = new Text(20, 20, "Topic");
Text mainText = new Text(20, 20, "Detail of Course");
VBox layoutOutside_Top = new VBox(5);
HBox layoutOutside_Right = new HBox();
HBox layoutOutside_Left = new HBox();
HBox layoutMiddle_Top = new HBox();
HBox layoutMiddle_CenterTop = new HBox(60);
HBox layoutMiddle_CenterBottom = new HBox();
Button goToParticipant = new Button("Back");
Button addCourse = new Button("Add Course");
Image imageSubject = new Image("Image/error404.jpg");
Image imageTeacher = new Image("Image/error404.jpg");
ImageView imageSubjectView = new ImageView(imageSubject);
ImageView imageTeacherView = new ImageView(imageTeacher);
Subject subject;
public void setTopicText(String topicText) {
this.topicText.setText(topicText);
}
public void setMainText(String mainText) {
this.mainText.setText(mainText);
}
public void setImageSubjectView(Image imageSubjectView) {
this.imageSubjectView.setImage(imageSubjectView);
}
public void setImageTeacherView(Image imageTeacherView) {
this.imageTeacherView.setImage(imageTeacherView);
}
public SubjectDetail(Stage window, User user) {
this.getStylesheets().add("Gui.css");
this.getStyleClass().addAll("middleLayoutCenter");
// ---------------------------------------------------<< Middle Layout
// >>---------------------------------------------------//
// -----------------------[ TOP ]--------------------------//
goToParticipant.getStyleClass().add("button-yellow");
topicText.setFont(Font.font("Courier", FontWeight.BOLD, FontPosture.ITALIC, 20));
topicText.setFill(Color.rgb(0, 0, 0));
topicText.setUnderline(true); // Underline for text3
layoutMiddle_Top.setStyle("-fx-border-width: 2px; -fx-border-color: green");
layoutMiddle_Top.setPadding(new Insets(20, 10, 25, 70));
layoutMiddle_Top.getChildren().addAll(topicText);
layoutMiddle_Top.setStyle("-fx-background-color: rgb(227, 17, 17), linear-gradient(to bottom, rgb(255, 233, 33) 0%, rgb(255, 174, 33) 100%);");
// -----------------------[ Center ]--------------------------//
imageSubjectView.setFitHeight(200);
imageSubjectView.setFitWidth(250);
imageTeacherView.setFitHeight(200);
imageTeacherView.setFitWidth(250);
layoutMiddle_CenterTop.setStyle("-fx-border-width: 2px; -fx-border-color: red");
layoutMiddle_CenterTop.setAlignment(Pos.TOP_CENTER);
layoutMiddle_CenterTop.setPadding(new Insets(0, 0, 25, 70));
layoutMiddle_CenterTop.getChildren().addAll(imageSubjectView, imageTeacherView);
// -----------------------[ BOTTOM ]--------------------------//
mainText.setFont(Font.font("Courier", FontWeight.THIN, FontPosture.ITALIC, 20));
mainText.setFill(Color.rgb(255, 255, 255));
layoutMiddle_CenterBottom.setStyle("-fx-border-width: 2px; -fx-border-color: #fcfcfc ;-fx-background-color:rgb(99,125,217) ");
layoutMiddle_CenterBottom.setPadding(new Insets(30, 0, 0, 30));
layoutMiddle_CenterBottom.getChildren().addAll(mainText);
// ---------------------------------------------------<< OUTSIDE LAYOUT
// >>---------------------------------------------------//
// -----------------------[BOTTOM LEFT ]--------------------------//
goToParticipant.setOnAction(actionEvent -> {
try {
window.setScene(new Scene(new Participant(window, user), 1280, 720));
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
});
addCourse.setOnAction(e -> {
boolean same = false;
for(int i = 0;i < user.getUserSubject().size(); i++){
if(user.getUserSubject().get(i).getSubjectString().equals(this.subject.getSubjectString())){
AlertBoxError.display("Error", "You already add this Subject.");
same = true;
break;
}
}
if(same == false){
user.addUserSubject(this.subject);
try {
AboutUser.updateUser(user);
} catch (ClassNotFoundException | IOException e2) {
e2.printStackTrace();
}
AlertBoxError.display("Finished", "Add Subject Succesfully");
try {
window.setScene(new Scene(new Participant(window, user), 1280, 720));
} catch (ClassNotFoundException | IOException e1) {
e1.printStackTrace();
}
}
});
layoutOutside_Left.setStyle("-fx-border-width: 5px; -fx-border-color: purple");
layoutOutside_Left.setAlignment(Pos.BOTTOM_LEFT);
layoutOutside_Left.getChildren().addAll(goToParticipant);
//-----------------------[ BOTTOM RIGHT]--------------------------//
layoutOutside_Right.setStyle("-fx-border-width: 5px; -fx-border-color: green");
layoutOutside_Right.setAlignment(Pos.BOTTOM_RIGHT);
layoutOutside_Right.getChildren().addAll(addCourse);
//-----------------------[ TOP ]--------------------------//
layoutOutside_Top.setStyle("-fx-border-width: 2px; -fx-border-color: yellow");
layoutOutside_Top.getChildren().addAll(layoutMiddle_Top,layoutMiddle_CenterTop,layoutMiddle_CenterBottom);
//---------------------------------------------------<< SET PANE >>---------------------------------------------------//
setTop(layoutOutside_Top);
setLeft(layoutOutside_Left);
setRight(layoutOutside_Right);
//<------------------------------------------------->>
}
public void setSubject(Subject subject) {
this.subject = subject;
}
}