我有一个问题,比如在执行过程时在JavaFX 不确定进度条上暴露的问题,但我使用javafx 对话框警报来使用如下代码显示进度条内部的对话框: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(); 问题是,在一个任务中,我调用了一个 Collection.Sort,我不知道它的持续时间,并且我无法在“任务调用”方法中执行 updateMessage,否则警报对话框会冻结。我想通过在第一个任务的调用中插入另一个管理 Collection.sort 的任务来解决这个问题,有没有更好的解决方案?
添加回答
举报
0/150
提交
取消