带有进度指示器和runLater的JavaFX runAsync
我的代码正在异步加载连接:带有进度指示器和runLater的JavaFX runAsync,javafx,tornadofx,Javafx,Tornadofx,我的代码正在异步加载连接: runAsync { controller.loadConnections(viewModel) } ui { table.items = it table.refresh() } 和内部负载连接方法: //read connections from file and then Platform.runLater(() -> { CollectionsKt.bind(connections, databases, Connec
runAsync {
controller.loadConnections(viewModel)
} ui {
table.items = it
table.refresh()
}
和内部负载连接
方法:
//read connections from file and then
Platform.runLater(() -> {
CollectionsKt.bind(connections, databases, ConnectionsModel::new);
connections.forEach(connection -> connection.setOwner(viewModel));
});
当我想将进度条添加为:
private val status = TaskStatus()
runAsync(status) {
controller.loadConnections(viewModel)
} ui {
table.items = it
table.refresh()
}
但它阻碍了进度指标。据我所知,有两项任务(progress
和Platform.runLater
)没有在async
中执行。但是我怎样才能让它工作呢?试试下面的代码:
CompletableFuture.runAsync(() -> {
for (int n = 1; n > size; n++)
progressBar.setProgress(n);
});
不直接相关(也不太熟悉TornadFX,只是假设table.refresh与普通javafx中的相同):不要使用它-似乎需要它可能表明数据/视图的连接不正确