Create JavaFX alert - Java JavaFX

Java examples for JavaFX:Alert

Description

Create JavaFX alert

Demo Code


import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.scene.control.Alert;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.stage.Modality;
import javafx.util.Duration;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;

public class Main{
    public static void alert(Alert.AlertType alertType, String title,
                String headerText, String contentText) {
            Alert alert = new Alert(alertType);
            alert.setTitle(title);//from   w ww  .ja  v  a2 s  .co  m

            if (headerText == null)
                alert.setHeaderText(null);
            else
                alert.setHeaderText(headerText);

            alert.setContentText(contentText);
            alert.initModality(Modality.APPLICATION_MODAL);
            alert.showAndWait();
        }
}

Related Tutorials