Newer
Older
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
package com.example.grademanager_gui;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonBar;
import javafx.scene.control.ButtonType;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import java.io.IOException;
import java.util.Optional;
public class DegreeModificationController extends MainController {
@FXML
protected TextField name;
@FXML
protected TextField bachelorDegree;
@FXML
protected TextField duration;
@FXML
protected TextField fees;
@FXML
protected TextField courses;
@FXML
protected TextField fieldOfStudy;
@FXML
protected TextField warning;
private Stage stage;
private Scene scene;
private FXMLLoader root;
@FXML
protected void onSaveButtonClick(ActionEvent event) throws IOException {
if(!name.getText().isBlank() && !bachelorDegree.getText().isBlank() &&
!duration.getText().isBlank() && !fees.getText().isBlank() &&
!courses.getText().isBlank() && !fieldOfStudy.getText().isBlank())
{
//studentList.add((String) name);
switchToMain(event);
}
else {
warning.setText("Bitte alle Felder ausfüllen");
}
}
@FXML
protected void switchToMain(ActionEvent event) throws IOException {
root = new FXMLLoader(Main.class.getResource("main.fxml"));
stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
scene = new Scene(root.load(), 960, 540);
stage.setTitle("Main");
stage.setScene(scene);
stage.show();
}
@FXML
protected void abortAndSwitchToMain(ActionEvent event) throws IOException {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("Bestätigung erforderlich");
alert.setHeaderText("Daten wurden nicht gespeichert. Änderungen verwerfen?");
ButtonType buttonTypeOne = new ButtonType("Ja");
ButtonType buttonTypeCancel = new ButtonType("Abbrechen", ButtonBar.ButtonData.CANCEL_CLOSE);
alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeCancel);
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == buttonTypeOne){
switchToMain(event);
}
}
}