0

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

Scath
  • 3,777
  • 10
  • 29
  • 40
RAINA
  • 802
  • 11
  • 22
  • You're mistaken about the possibilities of fxml. You cannot call `JFXDialog.show` from fxml. Since it's not possible with fxml alone, you cannot achieve something like this with SceneBuilder only. – fabian Jun 25 '18 at 09:18

1 Answers1

1
    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..

RAINA
  • 802
  • 11
  • 22