-
Notifications
You must be signed in to change notification settings - Fork 161
/
Copy pathController.java
65 lines (53 loc) · 1.65 KB
/
Controller.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
package home.controllers;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.stage.Modality;
import javafx.stage.Stage;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
public class Controller implements Initializable {
@FXML
private Button btnDashboard;
@FXML
private Button btnStudents;
@FXML
private Button btn_Timetable;
@FXML
private Button btnSettings;
@FXML
private Button btnUpdate;
@FXML
private Button btnClasses;
//my bad - the freaking mouse event
@FXML
private void handleButtonClicks(javafx.event.ActionEvent mouseEvent) {
if (mouseEvent.getSource() == btnDashboard) {
loadStage("/fxml/Dashboard.fxml");
} else if (mouseEvent.getSource() == btnStudents) {
loadStage("/fxml/Students.fxml");
} else if (mouseEvent.getSource() == btn_Timetable) {
loadStage("/fxml/Timetable.fxml");
}
}
@Override
public void initialize(URL location, ResourceBundle resources) {
}
private void loadStage(String fxml) {
try {
Parent root = FXMLLoader.load(getClass().getResource(fxml));
Stage stage = new Stage();
stage.setScene(new Scene(root));
stage.getIcons().add(new Image("/icons/icon.png"));
stage.initModality(Modality.APPLICATION_MODAL);
stage.show();
} catch (IOException e) {
e.printStackTrace();
}
}
}