1

I'm trying to show a loading popup when my program is running tasks in the background. I'm using Jfoenix for my program to give it the material design look, and I'm trying to use JFXDialog to display the loading popup. I created a popup in a stack pane using scene builder...

<?xml version="1.0" encoding="UTF-8"?>

<?import com.jfoenix.controls.JFXSpinner?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>


<StackPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="70.0" prefWidth="180.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <JFXSpinner>
         <padding>
            <Insets right="100.0" />
         </padding>
      </JFXSpinner>
      <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Loading">
         <StackPane.margin>
            <Insets left="50.0" />
         </StackPane.margin>
         <font>
            <Font name="Roboto Medium" size="20.0" />
         </font>
      </Text>
   </children>
</StackPane>

I am trying to use this in a JFXDialog...

private void createLoadingScreen() throws IOException{
    StackPane pane = FXMLLoader.load(getClass().getResource("LoadingScreen.fxml));
    StackPane stackPane = new StackPane();
    mLoad = new JFXDialog(stackPane, pane, JFXDialog.DialogTransition.CENTER);
}

I know that I'm not exactly doing this right, since it doesn't show up when I try to bring it up at the appropriate time. However, I don't know what I'm doing wrong exactly. Anyone have any pointers on this?

1 Answers1

2

Try this way:

Parent parent = FXMLLoader.load(getClass().getResource("your fxml file.fxml"));
JFXDialogLayout dialogLayout = new JFXDialogLayout();
dialogLayout.setBody(parent);
JFXDialog dialog = new JFXDialog(stackpane, dialogLayout, JFXDialog.DialogTransition.BOTTOM);
dialog.show();

the stackpane is the id of my StackPane in fxml file. You have to use the stackpane for JFXDialog. It worked for me.

AliXo
  • 21
  • 4