ciao andbin!
intendi una cosa del genere:Sì, certo. Una soluzione: passare il Task<Void> task al execTask(). Ma non è l'unica soluzione!
per poi fare:codice:public class BackgroundTask { public void execTask(Task<Void> task) throws InterruptedException { LoadingDialog loadingDialog = new LoadingDialog(); loadingDialog.activateProgressBar(task); task.setOnSucceeded(event -> { loadingDialog.getDialogStage().close(); }); task.setOnCancelled(event -> { loadingDialog.getDialogStage().close(); }); loadingDialog.getDialogStage().show(); Thread thread = new Thread(task); thread.start(); } }
??codice:private void updateBooks() { try { BackgroundTask bt = new BackgroundTask(); Task<Void> task = new Task<Void>() { @Override public Void call() throws InterruptedException { try { jsb.launchService("all_books"); jsb.launchService("all_authors"); jsb.launchService("all_editors"); jsb.launchService("graph_authors"); jsb.launchService("graph_editors"); jsb.download(UrlAndPath.JSON_LIBRI); jsb.download(UrlAndPath.JSON_AUTORI); jsb.download(UrlAndPath.JSON_EDITORI); setTable(); } catch (IOException e) { GenericDialog.showDialog(e.getMessage(), Alert.AlertType.ERROR); } return null; } }; bt.execTask(task); } catch (InterruptedException e) { } }
uhm penso di non aver capito bene che intendi!Tra l'altro c'è una questione: BackgroundTask non ha "stato" (non vedo sue variabili di istanza, almeno per quanto postato). Quindi una istanza di BackgroundTask a chi/cosa serve?

Rispondi quotando