javafxfxmlscenebuilderjfoenix

Cant make JDialogBox of jfoenix library using scene builder


Can somebody explain how to use Dialogue box from above library through XML. Without coding the dialog box using java, Can't I just design it from scene builder by dragging and dropping component.

I have already tried it but when I run the program dialog box is not visible.

Would be really helpful if someone can share a working example or even a link without using this method.

How to create a dialog using JFXDialog of JFoenix in JavaFX


Solution

  •     Double height = posCenterAnchor.getHeight();
        Double width = posCenterAnchor.getWidth();
    
        StackPane stackPane = new StackPane();
        AnchorPane.setTopAnchor(stackPane, 20.0);  // adding anchor pane margins
        AnchorPane.setLeftAnchor(stackPane, 20.0);
        AnchorPane.setRightAnchor(stackPane, 20.0);
        AnchorPane.setBottomAnchor(stackPane, 20.0);
        posCenterAnchor.getChildren().add(stackPane);
    
        JFXDialogLayout jfxDialogLayout = new JFXDialogLayout();
        Parent parent;
        try {
            parent = FXMLLoader.load(getClass().getResource("/Views/SelectCustomer.fxml"));
            jfxDialogLayout.getChildren().add(parent);
            JFXDialog jfxDialog = new JFXDialog(stackPane, jfxDialogLayout, JFXDialog.DialogTransition.CENTER, true);
            jfxDialog.show();
        } catch (Exception e) {
            e.printStackTrace();
        }
    

    just figured it out..all i had to do is ,just crate the content of the dialog box in a separate layout file and through code by creating a new dialog object then adding that layout to a dialog box...simple...wonder where went wrong..