Search in sources :

Example 1 with JFXAlert

use of com.jfoenix.controls.JFXAlert in project JFoenix by jfoenixadmin.

the class DialogController method init.

/**
 * init fxml when loaded.
 */
@PostConstruct
public void init() {
    root.getChildren().remove(dialog);
    centerButton.setOnAction(action -> {
        dialog.setTransitionType(DialogTransition.CENTER);
        dialog.show((StackPane) context.getRegisteredObject(CONTENT_PANE));
    });
    topButton.setOnAction(action -> {
        dialog.setTransitionType(DialogTransition.TOP);
        dialog.show((StackPane) context.getRegisteredObject(CONTENT_PANE));
    });
    rightButton.setOnAction(action -> {
        dialog.setTransitionType(DialogTransition.RIGHT);
        dialog.show((StackPane) context.getRegisteredObject(CONTENT_PANE));
    });
    bottomButton.setOnAction(action -> {
        dialog.setTransitionType(DialogTransition.BOTTOM);
        dialog.show((StackPane) context.getRegisteredObject(CONTENT_PANE));
    });
    leftButton.setOnAction(action -> {
        dialog.setTransitionType(DialogTransition.LEFT);
        dialog.show((StackPane) context.getRegisteredObject(CONTENT_PANE));
    });
    acceptButton.setOnAction(action -> dialog.close());
    alertButton.setOnAction(action -> {
        JFXAlert alert = new JFXAlert((Stage) alertButton.getScene().getWindow());
        alert.initModality(Modality.APPLICATION_MODAL);
        alert.setOverlayClose(false);
        JFXDialogLayout layout = new JFXDialogLayout();
        layout.setHeading(new Label("Modal Dialog using JFXAlert"));
        layout.setBody(new Label("Lorem ipsum dolor sit amet, consectetur adipiscing elit," + " sed do eiusmod tempor incididunt ut labore et dolore magna" + " aliqua. Utenim ad minim veniam, quis nostrud exercitation" + " ullamco laboris nisi ut aliquip ex ea commodo consequat."));
        JFXButton closeButton = new JFXButton("ACCEPT");
        closeButton.getStyleClass().add("dialog-accept");
        closeButton.setOnAction(event -> alert.hideWithAnimation());
        layout.setActions(closeButton);
        alert.setContent(layout);
        alert.show();
    });
}
Also used : Label(javafx.scene.control.Label) JFXButton(com.jfoenix.controls.JFXButton) JFXAlert(com.jfoenix.controls.JFXAlert) JFXDialogLayout(com.jfoenix.controls.JFXDialogLayout) PostConstruct(javax.annotation.PostConstruct)

Aggregations

JFXAlert (com.jfoenix.controls.JFXAlert)1 JFXButton (com.jfoenix.controls.JFXButton)1 JFXDialogLayout (com.jfoenix.controls.JFXDialogLayout)1 Label (javafx.scene.control.Label)1 PostConstruct (javax.annotation.PostConstruct)1