Skip to content
Snippets Groups Projects
NotificationPopUp.java 1.03 KiB
Newer Older
package com.application.GUI;

import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;

public class NotificationPopUp {

    public static void displayNotificationWindow(String message){

        Stage window = new Stage();
        window.initModality(Modality.APPLICATION_MODAL);
        window.setTitle("Moisture Check");

        Label messageLabel = new Label();
        messageLabel.setText(message);

        Button close = new Button("Close");
        close.setOnAction(event -> window.close());

        VBox layout = new VBox(10);
        layout.setAlignment(Pos.CENTER);
        layout.getChildren().addAll(messageLabel,close);

        Scene scene = new Scene(layout, 300, 200);
        scene.getStylesheets().add(InputPopUpWindow.class.getResource("/com.application/CSS/styleSheet.css").toExternalForm());
        window.setScene(scene);
        window.showAndWait();
    }

}