show Error Internationalization via JavaFX Alert - Java JavaFX

Java examples for JavaFX:Alert

Description

show Error Internationalization via JavaFX Alert

Demo Code


import javafx.scene.control.Alert;
import java.util.Optional;

public class Main{
    public static void showErrorI18n(Optional<String> headerProperty,
            Optional<String> messageProperty) {
        String title = I18n.resourceBundle.getString("general.error.title");
        String header = headerProperty.isPresent() ? I18n.resourceBundle
                .getString(headerProperty.get()) : null;
        String content = messageProperty.isPresent() ? I18n.resourceBundle
                .getString(messageProperty.get()) : I18n.resourceBundle
                .getString("general.error.text");
        showError(title, header, content);
    }/*from   w ww . ja v  a2 s . com*/
    public static void showError(String title, String header, String message) {
        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setTitle(title);
        alert.setHeaderText(header);
        alert.setContentText(message);
        alert.showAndWait();
    }
}

Related Tutorials