-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomepage.java
More file actions
186 lines (151 loc) Β· 7.66 KB
/
Homepage.java
File metadata and controls
186 lines (151 loc) Β· 7.66 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
/*
* Written by Eric Long & Thao Nguyen
* Edited by Frances Belleza
*
*/
package s25.cs151.application;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
public class Homepage extends Application {
private String currentSemester = "Spring"; // Instance variable for current semester
private int currentYear = 2025; // Instance variable for current year
private Stage stage;
public Homepage(Stage primaryStage) {
this.stage = primaryStage;
}
@Override
public void start(Stage primaryStage) {
this.stage= primaryStage;
// Loading in the Istok Web font
Font istokFont = Font.font("Istok Web", 16);
// Button dashboardButton = new Button("Dashboard");
// Button settingButton = new Button("Setting");
Button addOfficeHoursButton = new Button("Add Office Hours");
Button addTimeSlotsButton = new Button("Add Time Slots");
Button addCourseButton = new Button("Add Course");
Button viewSemesterButton = new Button("View Semester Office Hours");
Button viewTimeSlotsButton = new Button("View Time Slots"); // π New Button
Button viewCoursesButton = new Button("View Courses");
Button addOfficeHoursScheduleButton = new Button("Add Office Hours Schedule"); // π New Button
Button viewAppointmentsButton = new Button("View Appointments"); // π New Button
Button viewSearchOfficeHoursPage = new Button("Search Office Hours");
System.out.println("Default JavaFX Font: " + javafx.scene.text.Font.getDefault()); //added this to check font we want to use (Istok Web)
// dashboard function will talk about it later
// dashboardButton.setOnAction(e -> handleDashBoard);
// setting button function will talk about it later
// settingButton.setOnAction(e -> handleDashBoard);
addOfficeHoursButton.setOnAction(e -> switchToOfficeHoursPage());
addTimeSlotsButton.setOnAction(e -> switchToTimeSlotsPage());
addCourseButton.setOnAction(e -> switchToCoursesPage());
viewSemesterButton.setOnAction(e -> switchToOfficeHoursTableView());
viewTimeSlotsButton.setOnAction(e -> switchToTimeSlotsTableView());
viewCoursesButton.setOnAction(e -> switchToCoursesTableView());
addOfficeHoursScheduleButton.setOnAction(e -> switchToOfficeHoursSchedulePage());
viewAppointmentsButton.setOnAction(e -> switchToAppointmentsTableView());
viewSearchOfficeHoursPage.setOnAction (e -> switchToSearchOfficeHoursPage());
Text firsTtitle = new Text("Welcome to");
firsTtitle.setFont(istokFont); // Apply Istok Web font
firsTtitle.setStyle("-fx-font-size: 16px; -fx-font-weight: bold;");
// ProfMeet Title π
Text emoji = new Text("\uD83D\uDCC5"); // The Unicode I used for π
emoji.setFont(Font.font("Istok Web", 40));
Text mainTitle = new Text("ProfMeet");
mainTitle.setFont(Font.font("Istok Web", 50)); // tile text size
mainTitle.setStyle("-fx-font-weight: bold;");
// Add the Emoji
HBox titleWithEmoji = new HBox(10, emoji, mainTitle); // 10px spacing between emoji and text
titleWithEmoji.setStyle("-fx-alignment: center;");
// Title Layout
VBox titleBox = new VBox(10, firsTtitle, titleWithEmoji); // 10 is the spacing between titles
titleBox.setStyle("-fx-alignment: center;");
// Labels for current semester and year
Label semesterLabel = new Label("Current Semester: " + currentSemester);
Label yearLabel = new Label("Current Year: " + currentYear);
// Apply Istok Web font to labels
semesterLabel.setFont(istokFont);
yearLabel.setFont(istokFont);
// Box containing the current semester and year
VBox infoBox = new VBox(10, semesterLabel, yearLabel);
infoBox.setMinSize(300, 80); // Fixed size, so that it doesn't follow the page expanding
infoBox.setMaxSize(300, 80);
infoBox.setStyle("-fx-border-color: #000; -fx-border-width: 2px; -fx-padding: 10px; -fx-alignment: center;");
// Center the text inside the box
StackPane centeredBox = new StackPane(infoBox);
centeredBox.setStyle("-fx-alignment: center;");
// Buttons layout
VBox buttonBox = new VBox(10, addOfficeHoursButton,
addTimeSlotsButton,
addCourseButton,
viewSemesterButton,
viewTimeSlotsButton,
viewCoursesButton,
addOfficeHoursScheduleButton,
viewAppointmentsButton,
viewSearchOfficeHoursPage);
buttonBox.setStyle("-fx-padding: 20; -fx-alignment: center;");
// Create a VBox to hold the main title and the box below it
VBox vbox = new VBox(20, titleBox, centeredBox, buttonBox);
vbox.setStyle("-fx-padding: 20; -fx-alignment: center; -fx-background-color: rgba(66, 223, 244, 0.40);");
// Create a Scene with a bigger window size
Scene scene = new Scene(vbox, 900, 600, Color.LIGHTBLUE);
// Set the Stage (window)
primaryStage.setTitle("Student Advisor Registration");
primaryStage.setScene(scene);
primaryStage.setMinWidth(900); // picks the width
primaryStage.setMinHeight(600); // picks the height
primaryStage.show();
}
// Handlers for the buttons
private void switchToOfficeHoursPage() {
// Open Office Hours Page in a same window
OfficeHoursPage officeHoursPage = new OfficeHoursPage();
Scene officeHoursScene = officeHoursPage.getScene(stage);
stage.setScene(officeHoursScene);
}
private void switchToTimeSlotsPage() {
//Open TimeSlots Page in the same window
TimeSlotsPage timeSlotsPage = new TimeSlotsPage(stage);
Scene timeSlotsScene = timeSlotsPage.getScene(stage);
stage.setScene(timeSlotsScene);
}
private void switchToCoursesPage() {
//Open Courses Page in the same window
CoursesPage coursesPage = new CoursesPage(stage);
Scene coursesScene = coursesPage.getScene(stage);
stage.setScene(coursesScene);
}
private void switchToOfficeHoursTableView() {
new OfficeHoursTableView().start(new Stage());
}
private void switchToTimeSlotsTableView() {
new TimeSlotsTableView().start(new Stage());
}
private void switchToCoursesTableView() {
new CoursesTableView().start(new Stage());
}
private void switchToOfficeHoursSchedulePage() {
OfficeHoursSchedulePage officeHoursSchedulePage = new OfficeHoursSchedulePage(stage);
Scene officeHoursScheduleScene = officeHoursSchedulePage.getScene(stage);
stage.setScene(officeHoursScheduleScene);
}
private void switchToAppointmentsTableView() {
new AppointmentsTableView().start(new Stage());
}
private void switchToSearchOfficeHoursPage() {
SearchOfficeHoursPage searchOfficeHoursPage = new SearchOfficeHoursPage(stage);
Scene searchOfficeHoursScene = searchOfficeHoursPage.getScene(stage);
stage.setScene(searchOfficeHoursScene);
}
public static void main(String[] args) {
launch(args);
}
}