diff --git a/bin/controllers/AddFlightController.class b/bin/controllers/AddFlightController.class new file mode 100644 index 0000000..d83822d Binary files /dev/null and b/bin/controllers/AddFlightController.class differ diff --git a/bin/controllers/LogbookController.class b/bin/controllers/LogbookController.class new file mode 100644 index 0000000..73380b2 Binary files /dev/null and b/bin/controllers/LogbookController.class differ diff --git a/bin/views/AddFlightScreen.class b/bin/views/AddFlightScreen.class index 5e67197..57928db 100644 Binary files a/bin/views/AddFlightScreen.class and b/bin/views/AddFlightScreen.class differ diff --git a/bin/views/ViewLogbookScreen.class b/bin/views/ViewLogbookScreen.class index 6daa3f3..826879f 100644 Binary files a/bin/views/ViewLogbookScreen.class and b/bin/views/ViewLogbookScreen.class differ diff --git a/flights.xml b/flights.xml index 48806f2..577780f 100644 --- a/flights.xml +++ b/flights.xml @@ -1,5 +1,5 @@ - + @@ -43,6 +43,166 @@ + + + + 1.0 + + + test + + + 11:00 + + + 12:00 + + + 2 + + + 2024-06-11 + + + asd + + + test + + + + + sad + + + ads + + + + äää + + + äää + + + + sad + + + + + + + + + 6.75 + + + max + + + 09:15 + + + 16:00 + + + 2 + + + 2024-06-14 + + + Kommentar + + + Max + + + + + max + + + max + + + + hallo + + + test + + + + max + + + + test + + + + + + + + + + 1.0 + + + mannheim + + + 12:00 + + + 13:00 + + + 1 + + + 2024-06-14 + + + max + + + newTest + + + true + + + + + max + + + max + + + + hallo + + + test + + + + max + + + + test + + + + + + diff --git a/pilots.xml b/pilots.xml index 09938fb..d645733 100644 --- a/pilots.xml +++ b/pilots.xml @@ -1,5 +1,5 @@ - + @@ -49,6 +49,32 @@ + + + + max + + + max + + + + hallo + + + test + + + + max + + + + test + + + + diff --git a/src/controllers/AddFlightController.java b/src/controllers/AddFlightController.java new file mode 100644 index 0000000..682d2df --- /dev/null +++ b/src/controllers/AddFlightController.java @@ -0,0 +1,109 @@ +package controllers; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.scene.control.*; +import javafx.stage.Stage; +import models.Flight; +import models.Flights; +import models.Pilot; +import models.Pilots; +import utils.XMLHelper; +import views.HomeScreen; + +import java.time.Duration; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.util.ArrayList; +import java.util.List; + +public class AddFlightController { + private Stage stage; + private DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm"); + + public AddFlightController(Stage stage) { + this.stage = stage; + } + + public ObservableList loadPilots() { + ObservableList pilotList = FXCollections.observableArrayList(); + Pilots pilots = (Pilots) XMLHelper.loadFromXML("pilots.xml"); + if (pilots != null) { + List pilotEntries = pilots.getPilots(); + pilotList.addAll(pilotEntries); + } + return pilotList; + } + + public void saveFlight(Flight newFlight, DatePicker datumField, TextField musterField, TextField abflugortField, + TextField abflugzeitField, TextField ankunftszeitField, TextField tToFField, TextField anzahlLandungenField, + ComboBox pilotComboBox, CheckBox nachtflugBox, TextField kommentarField) { + try { + double flightDuration = Double.parseDouble(tToFField.getText().replace(',', '.')); + int landings = Integer.parseInt(anzahlLandungenField.getText()); + boolean isNachtflug = nachtflugBox.isSelected(); + + newFlight.setDatum(datumField.getValue()); + newFlight.setMuster(musterField.getText()); + newFlight.setAbflugort(abflugortField.getText()); + newFlight.setAbflugzeit(abflugzeitField.getText()); + newFlight.setAnkunftszeit(ankunftszeitField.getText()); + newFlight.setTToF(flightDuration); + newFlight.setAnzahlLandungen(landings); + newFlight.setPilot(pilotComboBox.getValue()); + newFlight.setNachtflug(isNachtflug); + newFlight.setKommentar(kommentarField.getText()); + newFlight.setDatumStr(datumField.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE)); + + Flights flights = (Flights) XMLHelper.loadFromXML("flights.xml"); + if (flights == null) { + flights = new Flights(new ArrayList<>()); + } + flights.getFlights().add(newFlight); + XMLHelper.saveToXML(flights, "flights.xml"); + + new HomeScreen(stage).display(); + } catch (NumberFormatException e) { + showAlert("Ungültige Eingabe", "Bitte stellen Sie sicher, dass die Flugdauer und die Anzahl der Landungen numerisch sind."); + } catch (IllegalArgumentException e) { + showAlert("Fehlende Eingabe", e.getMessage()); + } catch (Exception e) { + showAlert("Fehler", "Es ist ein Fehler beim Speichern des Flugs aufgetreten."); + e.printStackTrace(); + } + } + + public double calculateFlightDuration(String abflugzeit, String ankunftszeit) throws DateTimeParseException { + LocalTime start = LocalTime.parse(abflugzeit, timeFormatter); + LocalTime end = LocalTime.parse(ankunftszeit, timeFormatter); + return (double) Duration.between(start, end).toMinutes() / 60; + } + + public boolean isValidTime(String time) { + try { + LocalTime.parse(time, timeFormatter); + return true; + } catch (DateTimeParseException e) { + return false; + } + } + + public void setErrorStyle(Control field) { + field.setStyle("-fx-border-color: red;"); + } + + public void clearFieldStyles(Control... fields) { + for (Control field : fields) { + field.setStyle(null); + } + } + + public void showAlert(String title, String message) { + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setTitle(title); + alert.setHeaderText(null); + alert.setContentText(message); + alert.showAndWait(); + } +} diff --git a/src/controllers/LogbookController.java b/src/controllers/LogbookController.java new file mode 100644 index 0000000..bff54f0 --- /dev/null +++ b/src/controllers/LogbookController.java @@ -0,0 +1,55 @@ +package controllers; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.stage.Stage; +import models.Flight; +import models.Flights; +import utils.XMLHelper; +import views.EditFlightScreen; +import views.HomeScreen; + +import java.util.List; + +public class LogbookController { + private Stage stage; + private ObservableList flightList; + + public LogbookController(Stage stage) { + this.stage = stage; + this.flightList = FXCollections.observableArrayList(); + loadFlights(); + } + + public ObservableList getFlightList() { + return flightList; + } + + private void loadFlights() { + Flights flights = (Flights) XMLHelper.loadFromXML("flights.xml"); + if (flights != null) { + List flightEntries = flights.getFlights(); + flightList.addAll(flightEntries); + } + } + + public void editFlight(Flight selectedFlight) { + if (selectedFlight != null) { + new EditFlightScreen(stage, selectedFlight).display(); + } else { + showAlert("Fehler", "Bitte wählen Sie einen Flug aus."); + } + } + + public void goBack() { + new HomeScreen(stage).display(); + } + + private void showAlert(String title, String message) { + javafx.scene.control.Alert alert = new javafx.scene.control.Alert(javafx.scene.control.Alert.AlertType.ERROR); + alert.setTitle(title); + alert.setHeaderText(null); + alert.setContentText(message); + alert.showAndWait(); + } +} diff --git a/src/views/AddFlightScreen.java b/src/views/AddFlightScreen.java index 64b9552..ed790ed 100644 --- a/src/views/AddFlightScreen.java +++ b/src/views/AddFlightScreen.java @@ -1,245 +1,149 @@ package views; -import javafx.collections.FXCollections; +import controllers.AddFlightController; import javafx.collections.ObservableList; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.*; -import javafx.scene.layout.BorderPane; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.stage.Stage; import models.Flight; -import models.Flights; import models.Pilot; -import models.Pilots; -import utils.XMLHelper; import java.time.LocalDate; -import java.time.LocalTime; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeParseException; -import java.util.ArrayList; -import java.util.List; public class AddFlightScreen { private Stage stage; - private DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm"); + private AddFlightController controller; public AddFlightScreen(Stage stage) { this.stage = stage; + this.controller = new AddFlightController(stage); } public void display() { Label label = new Label("Flugdaten eingeben:"); label.setStyle("-fx-font-size: 18px; -fx-font-weight: bold;"); - DatePicker datumField = new DatePicker(); - TextField musterField = new TextField(); - TextField abflugortField = new TextField(); - TextField abflugzeitField = new TextField(); - TextField ankunftszeitField = new TextField(); - TextField tToFField = new TextField(); - TextField anzahlLandungenField = new TextField(); - CheckBox nachtflugBox = new CheckBox("Nachtflug"); - TextField kommentarField = new TextField(); + + Label datumLabel = new Label("Datum:"); + DatePicker datumField = new DatePicker(LocalDate.now()); // Set today's date - datumField.setPromptText("YYYY-MM-DD"); + Label musterLabel = new Label("Muster:"); + TextField musterField = new TextField(); musterField.setPromptText("Muster"); + + Label abflugortLabel = new Label("Abflugort:"); + TextField abflugortField = new TextField(); abflugortField.setPromptText("Abflugort"); + + Label abflugzeitLabel = new Label("Abflugzeit:"); + TextField abflugzeitField = new TextField(); abflugzeitField.setPromptText("HH:mm"); + + Label ankunftszeitLabel = new Label("Ankunftszeit:"); + TextField ankunftszeitField = new TextField(); ankunftszeitField.setPromptText("HH:mm"); + + Label tToFLabel = new Label("Flugdauer (Stunden):"); + TextField tToFField = new TextField(); tToFField.setPromptText("Flugdauer (Stunden)"); + tToFField.setEditable(false); // Make the field read-only + tToFField.setStyle("-fx-control-inner-background: #E0E0E0;"); // Gray out the field + + Label anzahlLandungenLabel = new Label("Anzahl der Landungen:"); + TextField anzahlLandungenField = new TextField(); anzahlLandungenField.setPromptText("Anzahl der Landungen"); + + Label nachtflugLabel = new Label("Nachtflug:"); + CheckBox nachtflugBox = new CheckBox(); + + Label kommentarLabel = new Label("Kommentar:"); + TextField kommentarField = new TextField(); kommentarField.setPromptText("Kommentar"); - // Nur numerische Eingaben für Flugdauer und Anzahl der Landungen zulassen - tToFField.setEditable(false); - anzahlLandungenField.textProperty().addListener((observable, oldValue, newValue) -> { - if (!newValue.matches("\\d*")) { - anzahlLandungenField.setText(oldValue); - } + ObservableList pilotList = controller.loadPilots(); + Label pilotLabel = new Label("Pilot:"); + ComboBox pilotComboBox = new ComboBox<>(pilotList); + + Button saveBtn = new Button("Speichern"); + saveBtn.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;"); + saveBtn.setOnAction(e -> { + Flight newFlight = new Flight(); + controller.clearFieldStyles(datumField, musterField, abflugortField, abflugzeitField, ankunftszeitField, tToFField, anzahlLandungenField, kommentarField); + + // Save the flight with the corrected TToF value + controller.saveFlight(newFlight, datumField, musterField, abflugortField, abflugzeitField, ankunftszeitField, tToFField, anzahlLandungenField, pilotComboBox, nachtflugBox, kommentarField); }); - // Validierung und Berechnung der Flugdauer - abflugzeitField.focusedProperty().addListener((observable, oldValue, newValue) -> { - if (!newValue) { - if (!isValidTime(abflugzeitField.getText())) { - abflugzeitField.setStyle("-fx-border-color: red;"); - } else { - abflugzeitField.setStyle(null); - calculateFlightDuration(abflugzeitField, ankunftszeitField, tToFField); - } - } - }); - - ankunftszeitField.focusedProperty().addListener((observable, oldValue, newValue) -> { - if (!newValue) { - if (!isValidTime(ankunftszeitField.getText())) { - ankunftszeitField.setStyle("-fx-border-color: red;"); - } else { - ankunftszeitField.setStyle(null); - calculateFlightDuration(abflugzeitField, ankunftszeitField, tToFField); - } - } - }); - - // Laden der Piloten für die Auswahlbox - Pilots pilotsData = (Pilots) XMLHelper.loadFromXML("pilots.xml"); - List pilotList = pilotsData != null ? pilotsData.getPilots() : new ArrayList<>(); - ObservableList pilots = FXCollections.observableArrayList(pilotList); - - ComboBox pilotComboBox = new ComboBox<>(pilots); - pilotComboBox.setPromptText("Pilot auswählen"); - - Button submitBtn = new Button("Hinzufügen"); - submitBtn.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;"); - submitBtn.setOnAction( - e -> handleAddFlight(datumField, musterField, abflugortField, abflugzeitField, ankunftszeitField, - tToFField, anzahlLandungenField, nachtflugBox.isSelected(), kommentarField, pilotComboBox)); - Button backButton = new Button("Zurück"); backButton.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;"); backButton.setOnAction(e -> new HomeScreen(stage).display()); - VBox vbox = new VBox(10, label, datumField, musterField, abflugortField, abflugzeitField, ankunftszeitField, - tToFField, anzahlLandungenField, nachtflugBox, kommentarField, pilotComboBox, submitBtn); + // Add listeners to the time fields to update the flight duration automatically + abflugzeitField.textProperty().addListener((observable, oldValue, newValue) -> updateFlightDuration(abflugzeitField, ankunftszeitField, tToFField)); + ankunftszeitField.textProperty().addListener((observable, oldValue, newValue) -> updateFlightDuration(abflugzeitField, ankunftszeitField, tToFField)); + + GridPane grid = new GridPane(); + grid.setAlignment(Pos.CENTER); + grid.setHgap(10); + grid.setVgap(10); + grid.setPadding(new Insets(20)); + + grid.add(label, 0, 0, 2, 1); + + grid.add(datumLabel, 0, 1); + grid.add(datumField, 1, 1); + grid.add(musterLabel, 0, 2); + grid.add(musterField, 1, 2); + grid.add(abflugortLabel, 0, 3); + grid.add(abflugortField, 1, 3); + grid.add(abflugzeitLabel, 0, 4); + grid.add(abflugzeitField, 1, 4); + grid.add(ankunftszeitLabel, 0, 5); + grid.add(ankunftszeitField, 1, 5); + grid.add(tToFLabel, 0, 6); + grid.add(tToFField, 1, 6); + grid.add(anzahlLandungenLabel, 0, 7); + grid.add(anzahlLandungenField, 1, 7); + grid.add(pilotLabel, 0, 8); + grid.add(pilotComboBox, 1, 8); + grid.add(nachtflugLabel, 0, 9); + grid.add(nachtflugBox, 1, 9); + grid.add(kommentarLabel, 0, 10); + grid.add(kommentarField, 1, 10); + + HBox buttonBox = new HBox(10, saveBtn, backButton); + buttonBox.setAlignment(Pos.CENTER); + + VBox vbox = new VBox(20, grid, buttonBox); vbox.setAlignment(Pos.CENTER); vbox.setPadding(new Insets(20)); vbox.setStyle("-fx-background-color: #E6F2FF;"); - BorderPane borderPane = new BorderPane(); - borderPane.setTop(backButton); - borderPane.setCenter(vbox); - BorderPane.setAlignment(backButton, Pos.TOP_LEFT); - BorderPane.setMargin(backButton, new Insets(10)); - - if (pilots.isEmpty()) { - Button addPilotBtn = new Button("Pilot hinzufügen"); - addPilotBtn.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;"); - addPilotBtn.setOnAction(e -> new ManagePilotProfileScreen(stage).display()); - vbox.getChildren().add(addPilotBtn); - } - - Scene scene = new Scene(borderPane, 800, 600); + Scene scene = new Scene(vbox, 800, 600); scene.getStylesheets().add(getClass().getResource("/resources/styles.css").toExternalForm()); stage.setScene(scene); stage.show(); } - private void calculateFlightDuration(TextField abflugzeitField, TextField ankunftszeitField, TextField tToFField) { - try { - LocalTime abflugzeit = LocalTime.parse(abflugzeitField.getText(), timeFormatter); - LocalTime ankunftszeit = LocalTime.parse(ankunftszeitField.getText(), timeFormatter); - long durationInMinutes = java.time.Duration.between(abflugzeit, ankunftszeit).toMinutes(); - if (durationInMinutes < 0) { - durationInMinutes += 24 * 60; // Falls über Mitternacht + private void updateFlightDuration(TextField abflugzeitField, TextField ankunftszeitField, TextField tToFField) { + String abflugzeit = abflugzeitField.getText(); + String ankunftszeit = ankunftszeitField.getText(); + + if (controller.isValidTime(abflugzeit) && controller.isValidTime(ankunftszeit)) { + double duration = controller.calculateFlightDuration(abflugzeit, ankunftszeit); + if (duration >= 0) { + tToFField.setText(String.valueOf(duration)); + } else { + controller.showAlert("Ungültige Zeit", "Die Ankunftszeit darf nicht vor der Abflugzeit liegen."); + tToFField.setText(""); } - double durationInHours = durationInMinutes / 60.0; - String formattedDuration = String.format("%.2f", durationInHours); - - tToFField.setText(formattedDuration); - } catch (DateTimeParseException e) { + } else { tToFField.setText(""); } } - - private boolean isValidTime(String time) { - try { - LocalTime.parse(time, timeFormatter); - return true; - } catch (DateTimeParseException e) { - return false; - } - } - - private void handleAddFlight(DatePicker datumField, TextField musterField, TextField abflugortField, - TextField abflugzeitField, TextField ankunftszeitField, TextField tToFField, - TextField anzahlLandungenField, boolean isNachtflug, TextField kommentarField, - ComboBox pilotComboBox) { - try { - clearFieldStyles(datumField, musterField, abflugortField, abflugzeitField, ankunftszeitField, - tToFField, anzahlLandungenField, kommentarField, pilotComboBox); - - if (datumField.getValue() == null || musterField.getText().isEmpty() || abflugortField.getText().isEmpty() - || - abflugzeitField.getText().isEmpty() || ankunftszeitField.getText().isEmpty() - || tToFField.getText().isEmpty() || - anzahlLandungenField.getText().isEmpty() || pilotComboBox.getValue() == null) { - throw new IllegalArgumentException("Bitte füllen Sie alle Felder aus."); - } - - if (!isValidTime(abflugzeitField.getText())) { - setErrorStyle(abflugzeitField); - throw new IllegalArgumentException("Ungültige Abflugzeit."); - } - - if (!isValidTime(ankunftszeitField.getText())) { - setErrorStyle(ankunftszeitField); - throw new IllegalArgumentException("Ungültige Ankunftszeit."); - } - - System.out.println("Flugdauer vor dem Parsen: " + tToFField.getText()); // Debug-Ausgabe - double flightDuration; - try { - // Ersetzen des Kommas durch einen Punkt - String flightDurationText = tToFField.getText().replace(",", "."); - flightDuration = Double.parseDouble(flightDurationText); - } catch (NumberFormatException e) { - setErrorStyle(tToFField); - throw new IllegalArgumentException("Flugdauer muss eine gültige Zahl sein."); - } - - int landings = Integer.parseInt(anzahlLandungenField.getText()); - - Flight newFlight = new Flight(); - newFlight.setDatum(datumField.getValue()); // Setzen des Datums als LocalDate - newFlight.setMuster(musterField.getText()); - newFlight.setAbflugort(abflugortField.getText()); - newFlight.setAbflugzeit(abflugzeitField.getText()); - newFlight.setAnkunftszeit(ankunftszeitField.getText()); - newFlight.setTToF(flightDuration); - newFlight.setAnzahlLandungen(landings); - newFlight.setPilot(pilotComboBox.getValue()); - newFlight.setNachtflug(isNachtflug); - newFlight.setKommentar(kommentarField.getText()); - newFlight.setDatumStr(datumField.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE)); // Setzen des DatumStr - - - Flights flights = (Flights) XMLHelper.loadFromXML("flights.xml"); - if (flights == null) { - flights = new Flights(new ArrayList<>()); - } - flights.getFlights().add(newFlight); - XMLHelper.saveToXML(flights, "flights.xml"); - - new HomeScreen(stage).display(); - } catch (NumberFormatException e) { - showAlert("Ungültige Eingabe", - "Bitte stellen Sie sicher, dass die Flugdauer und die Anzahl der Landungen numerisch sind."); - } catch (IllegalArgumentException e) { - showAlert("Fehlende Eingabe", e.getMessage()); - } catch (Exception e) { - showAlert("Fehler", "Es ist ein Fehler beim Speichern des Flugs aufgetreten."); - e.printStackTrace(); - } - } - - private void setErrorStyle(Control field) { - field.setStyle("-fx-border-color: red;"); - } - - private void clearFieldStyles(Control... fields) { - for (Control field : fields) { - field.setStyle(null); - } - } - - private void showAlert(String title, String message) { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle(title); - alert.setHeaderText(null); - alert.setContentText(message); - alert.showAndWait(); - } } diff --git a/src/views/ViewLogbookScreen.java b/src/views/ViewLogbookScreen.java index 2b99472..39eb5cf 100644 --- a/src/views/ViewLogbookScreen.java +++ b/src/views/ViewLogbookScreen.java @@ -1,7 +1,7 @@ package views; +import controllers.LogbookController; import javafx.beans.property.SimpleStringProperty; -import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.geometry.Insets; import javafx.geometry.Pos; @@ -11,18 +11,17 @@ import javafx.scene.layout.BorderPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; import models.Flight; -import models.Flights; -import utils.XMLHelper; import java.time.LocalDate; import java.time.format.DateTimeFormatter; -import java.util.List; public class ViewLogbookScreen { private Stage stage; + private LogbookController controller; public ViewLogbookScreen(Stage stage) { this.stage = stage; + this.controller = new LogbookController(stage); } public void display() { @@ -68,28 +67,19 @@ public class ViewLogbookScreen { table.getColumns().addAll(datumCol, musterCol, abflugortCol, abflugzeitCol, ankunftszeitCol, tToFCol, anzahlLandungenCol, pilotCol, nachtflugCol, kommentarCol); - ObservableList flightList = FXCollections.observableArrayList(); - Flights flights = (Flights) XMLHelper.loadFromXML("flights.xml"); - if (flights != null) { - List flightEntries = flights.getFlights(); - flightList.addAll(flightEntries); - } + ObservableList flightList = controller.getFlightList(); table.setItems(flightList); Button editBtn = new Button("Bearbeiten"); editBtn.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;"); editBtn.setOnAction(e -> { Flight selectedFlight = table.getSelectionModel().getSelectedItem(); - if (selectedFlight != null) { - new EditFlightScreen(stage, selectedFlight).display(); - } else { - showAlert("Fehler", "Bitte wählen Sie einen Flug aus."); - } + controller.editFlight(selectedFlight); }); Button backButton = new Button("Zurück"); backButton.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;"); - backButton.setOnAction(e -> new HomeScreen(stage).display()); + backButton.setOnAction(e -> controller.goBack()); VBox vbox = new VBox(20, label, table, editBtn, backButton); vbox.setAlignment(Pos.CENTER); @@ -102,12 +92,4 @@ public class ViewLogbookScreen { stage.setScene(scene); stage.show(); } - - private void showAlert(String title, String message) { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle(title); - alert.setHeaderText(null); - alert.setContentText(message); - alert.showAndWait(); - } }