From 9c2f8856b45c72ffb7a4ca49e957d0d0e09d889b Mon Sep 17 00:00:00 2001 From: pawelsa Date: Thu, 14 May 2026 21:52:20 +0200 Subject: [PATCH] feat: Implement UIAlert class for transaction alerts --- .../idi/idatt/view/components/ui/UIAlert.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/java/edu/ntnu/idi/idatt/view/components/ui/UIAlert.java diff --git a/src/main/java/edu/ntnu/idi/idatt/view/components/ui/UIAlert.java b/src/main/java/edu/ntnu/idi/idatt/view/components/ui/UIAlert.java new file mode 100644 index 0000000..78c7341 --- /dev/null +++ b/src/main/java/edu/ntnu/idi/idatt/view/components/ui/UIAlert.java @@ -0,0 +1,26 @@ +package edu.ntnu.idi.idatt.view.components.ui; + +import javafx.scene.control.Alert; +import javafx.scene.control.Alert.AlertType; +import javafx.scene.control.ButtonType; + +public class UIAlert { + + Alert alert = new Alert(AlertType.CONFIRMATION); + ButtonType confirm = new ButtonType("Confirm"); + ButtonType cancel = new ButtonType("Cancel"); + + public UIAlert(String title, String header, String content) { + alert.setTitle(title); + alert.setHeaderText(header); + alert.setContentText(content); + + alert.getButtonTypes().setAll(confirm, cancel); + } + + public boolean displayAwaitResponse() { + ButtonType type = alert.showAndWait().orElse(cancel); + return type == confirm ? true : false; + } + +}