我有一個(gè)問題,比如在執(zhí)行過程時(shí)在JavaFX 不確定進(jìn)度條上暴露的問題,但我使用javafx 對話框警報(bào)來使用如下代碼顯示進(jìn)度條內(nèi)部的對話框:Alert busyWaitAlert = new Alert(Alert.AlertType.INFORMATION);busyWaitAlert.setContentText("Operation in progress"); ButtonType cancelButton = new ButtonType("Cancel", ButtonBar.ButtonData.FINISH); busyWaitAlert.getButtonTypes().setAll(cancelButton);busyWaitAlert.setTitle("Running Operation");busyWaitAlert.setHeaderText("Please wait... ");ProgressBar progressBar = new ProgressBar(); busyWaitAlert.setGraphic(progressBar);progressBar.setProgress(ProgressBar.INDETERMINATE_PROGRESS);Task<Boolean> task;task = new Task<Boolean>() { @Override public Boolean call() throws Exception { Collections.sort(LnkListImportedToDb, new importDataToDb.DataItemImportedToDbTimeCmp1()); return true; } }; task.setOnSucceeded((e) -> { busyWaitAlert.close(); }); progressBar.progressProperty().bind(task.progressProperty()); busyWaitAlert.contentTextProperty().bind(task.messageProperty()); new Thread(task).start(); 問題是,在一個(gè)任務(wù)中,我調(diào)用了一個(gè) Collection.Sort,我不知道它的持續(xù)時(shí)間,并且我無法在“任務(wù)調(diào)用”方法中執(zhí)行 updateMessage,否則警報(bào)對話框會凍結(jié)。我想通過在第一個(gè)任務(wù)的調(diào)用中插入另一個(gè)管理 Collection.sort 的任務(wù)來解決這個(gè)問題,有沒有更好的解決方案?
添加回答
舉報(bào)
0/150
提交
取消