-
Notifications
You must be signed in to change notification settings - Fork 0
/
AlertBox.java
150 lines (115 loc) · 6.12 KB
/
AlertBox.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
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import java.io.IOException;
public class AlertBox extends BorderPane {
// THIS CLASS HAVE 2 IMPORTANT
// 1.IF PARTICIPANT CLICK ADD TOPIC CONSTRUCTOR Alertbox(Stage window) will be
// work
// 2.IF PARTICIPANT CLICK ADD TOPIC AND DIDN'T CHOOSE TOPIC BEFORE(choose
// radiobutton) public static void alertBoxAddCourse() WILL BE WORK
Participant participant;
Participant participant2;
Stage window;
// ----------------------------------------------------<< LABEL AND TEXT STRING
// >>--------------------------------------------------------//
Label topicName = new Label(" Topic Name : ");
TextField topicNameText = new TextField();
// ----------------------------------------------------<< PANE LAYOUT
// >>--------------------------------------------------------//
BorderPane outSideLayOut_Center = new BorderPane();
VBox middleLayout_Center = new VBox(10);
HBox inSideLayOut_Roll1 = new HBox(10);
HBox inSideLayOut_Roll2 = new HBox(10);
HBox inSideLayOut_Roll3 = new HBox();
HBox middleLayout_Bottom = new HBox();
// --------------------------------------------------<< BUTTON
// >>----------------------------------------------------------//
Button backToCourse = new Button("Back");
Button addTopic = new Button("add Topic");
// ------------------------------------------------------------------------------------------------------------//
public AlertBox(Stage window, User user) {
this.window = window;
this.getStylesheets().add("Gui.css");
topicNameText.setPromptText(" Add topic for study"); //
// ------------------------------------------------------------------------------------------------------------//
inSideLayOut_Roll2.setAlignment(Pos.CENTER_LEFT);
inSideLayOut_Roll2.getChildren().addAll(topicName, topicNameText);
inSideLayOut_Roll3.getChildren().addAll(addTopic);
inSideLayOut_Roll3.setAlignment(Pos.CENTER);
addTopic.setOnAction(actionEvent -> {
if (topicNameText.getText().equals(null) || topicNameText.getText().equals("")) {
AlertBoxError.display("Error", "Please Fillin Topic Name");
} else
try {
if (Course.checkTopic(topicNameText.getText()) == false) {
AlertBoxError.display("Error", "This topic alreadu exist.");
} else {
try {
Course.createTopic(topicNameText.getText());
System.out.println("Add File");
participant = new Participant(window, user);
participant.getStylesheets().add("Gui.css");
window.setScene(new Scene(participant, 1280, 720));
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
} catch (ClassNotFoundException | IOException e) {
e.printStackTrace();
}
});
//------------------------------------------------------------------------------------------------------------//
middleLayout_Center.setAlignment(Pos.CENTER);
middleLayout_Center.getChildren().addAll(inSideLayOut_Roll2, inSideLayOut_Roll3);
middleLayout_Center.setStyle("-fx-border-width: 2px; -fx-border-color: red");
//------------------------------------------------------------------------------------------------------------//
middleLayout_Bottom.getChildren().addAll(backToCourse);
middleLayout_Bottom.setAlignment(Pos.BOTTOM_LEFT);
middleLayout_Bottom.setStyle("-fx-border-width: 2px; -fx-border-color: red");
backToCourse.setOnAction(actionEvent -> {
try {
participant2 = new Participant(window, user);
participant2.getStylesheets().add("Gui.css");
window.setScene(new Scene(participant2,700,700));
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
});
//------------------------------------------------------------------------------------------------------------//
outSideLayOut_Center.setCenter(middleLayout_Center);
outSideLayOut_Center.setBottom(middleLayout_Bottom);
//------------------------------------------------------------------------------------------------------------//
setCenter(outSideLayOut_Center);
}
//------------------------------------------------------------------------------------------------------------//
// IF YOU DID'T CHOOSE RADIOBUTTON AND YOU CLICK ADD SUBJECT,THIS FUNCTION WILL BE POPUP
public static void alertBoxAddCourse(){
Stage window = new Stage();
window.initModality(Modality.APPLICATION_MODAL);
window.setTitle("Warning!");
window.setMinWidth(450);
window.setMinHeight(250);
Label label = new Label();
label.setText("Please Selected Topic to add your subject");
Button closeButton = new Button("Close this window");
closeButton.setOnAction(actionEvent -> window.close());
VBox layout = new VBox(10);
layout.getChildren().addAll(label, closeButton);
layout.getStylesheets().add("Gui.css");
layout.setAlignment(Pos.CENTER);
//Display window and wait for it to be closed before returning
Scene scene = new Scene(layout);
window.setScene(scene);
window.showAndWait();
}
}