Class ModalPane

java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
javafx.scene.control.Control
atlantafx.base.controls.ModalPane
All Implemented Interfaces:
javafx.css.Styleable, javafx.event.EventTarget, javafx.scene.control.Skinnable

public class ModalPane extends javafx.scene.control.Control
A container for displaying application dialogs ot top of the current scene without opening a modal Stage. It's a translucent (glass) pane that can hold arbitrary content as well as animate its appearance.

When displayProperty() value is changed the modal pane modifies own Node.viewOrderProperty() value accordingly, thus moving itself on top of the parent container or vise versa. You can change the target view order value via the constructor param. This also means that one must not change the modal pane Node.viewOrderProperty() property manually.

Example:


 public class ModalPaneExample extends Application {

     @Override
     public void start(Stage primaryStage) {
         setUserAgentStylesheet(new PrimerLight().getUserAgentStylesheet());

         class Dialog extends VBox {

             public Dialog(int width, int height, Runnable closeHandler) {
                 super();

                 setMinSize(width, height);
                 setMaxSize(width, height);
                 setSpacing(10);
                 setStyle("-fx-background-color: -color-bg-default;");

                 var closeBtn = new Button("Close");
                 closeBtn.setOnAction(e -> closeHandler.run());
                 getChildren().setAll(closeBtn);
             }
         }

         var modalPane = new ModalPane();
         modalPane.setAlignment(Pos.CENTER);

         var dialogOpenBtn = new Button("Open Dialog");
         dialogOpenBtn.setOnAction(e ->
             modalPane.show(new Dialog(300, 300, () -> modalPane.hide(true)))
         );

         var root = new StackPane();
         root.getChildren().addAll(new VBox(dialogOpenBtn), modalPane);

         primaryStage.setScene(new Scene(root, 600, 600));
         primaryStage.show();
     }
 }