I experienced the same problem while trying to add a splash screen for my program. This is how my code was 
CircleTest pForm = new CircleTest();
Task<Void> task = new Task<Void>() {
    @Override
    public Void call() {
        try {
            FXMLLoader loader = new FXMLLoader(
                Main.class.getResource("/newRegistration/HomePage.fxml"));
            AnchorPane page = (AnchorPane) loader
                .load();
            dialogStagee.getIcons().add(new Image("/piks/showthumb.png"));
            dialogStagee.setTitle("WALGOTECH SOLUTIONS: 0703445354");
            dialogStagee.initModality(Modality.APPLICATION_MODAL);
            Scene scene = new Scene(page);
            dialogStagee.setScene(scene);
            HomePageController controller = loader.getController();
            controller.setDialogStage(dialogStagee);
            dialogStagee.setMaximized(true);
            dialogStagee.initStyle(StageStyle.UNDECORATED);
            conn.prepareStatement(
                "INSERT INTO `logs`(`date`,`user`,`Terminal`,`Action`)"
                    + " VALUES ('"
                    + (java.time.LocalDate.now()
                    + " "
                    + java.time.LocalTime.now().getHour()
                    + ":"
                    + java.time.LocalTime.now().getMinute()
                    + ":" + java.time.LocalTime.now().getSecond())
                    + "',"
                    + "'"
                    + DbConnector.getMyVariablepatientvameloginCategory()
                                                        .split("as")[1]
                    + "',"
                    + "'"
                    + StartPageController.hostname
                    + "',"
                    + " 'Logged in into Registration')")
                                        .execute();
            } catch (Exception e) {
                    e.printStackTrace();
            }   
            return null;
        }
};
pForm.activateProgressBar(task);
task.setOnSucceeded(event -> {
    dialogStagee.show();
    try {
    } catch (Exception e) {
    }
    pForm.getDialogStage().close();
});
pForm.getDialogStage().show();
dialogStage.close();
Thread thread = new Thread(task);
thread.start();
Running this gave a 'not on fx application'. By adding Platform.runLater() inside my task, that solved the issue.
Now, this is how I currently have my code: 
CircleTest pForm = new CircleTest();
Task<Void> task = new Task<Void>() {
    @Override
    public Void call() {
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                try {
                    FXMLLoader loader = new FXMLLoader(
                                        Main.class
                                                .getResource("/newRegistration/HomePage.fxml"));
                    AnchorPane page = (AnchorPane) loader
                                        .load();
                    dialogStagee.getIcons().add(
                                        new Image("/piks/showthumb.png"));
                    dialogStagee
                                        .setTitle("WALGOTECH SOLUTIONS: 0703445354");
                    dialogStagee
                                        .initModality(Modality.APPLICATION_MODAL);
                    Scene scene = new Scene(page);
                    dialogStagee.setScene(scene);
                    HomePageController controller = loader
                                        .getController();
                    controller.setDialogStage(dialogStagee);
                    dialogStagee.setMaximized(true);
                    dialogStagee.initStyle(StageStyle.UNDECORATED);
                    conn.prepareStatement(
                        "INSERT INTO `logs`(`date`,`user`,`Terminal`,`Action`)"
                        + " VALUES ('"
                        + (java.time.LocalDate.now()
                        + " "
                        + java.time.LocalTime.now().getHour()
                        + ":"
                        + java.time.LocalTime.now().getMinute()
                        + ":" + java.time.LocalTime.now().getSecond())
                        + "',"
                        + "'"
                        + DbConnector.getMyVariablepatientvameloginCategory()
                                                        .split("as")[1]
                        + "',"
                        + "'"
                        + StartPageController.hostname
                        + "',"
                        + " 'Logged in into Registration')")
                                        .execute();
                } catch (Exception e) {
                    e.printStackTrace();
                }   
            }
        });
        return null;
    }
};
pForm.activateProgressBar(task);
task.setOnSucceeded(event -> {
    dialogStagee.show();
    try {
    } catch (Exception e) {
    }
    pForm.getDialogStage().close();
});
pForm.getDialogStage().show();
dialogStage.close();
// dialogStage.setDisable(true);
Thread thread = new Thread(task);
thread.start();
I hope this will help you solve the problem. Cheers.