0
从任务API叫我使用这个类更新标签JavaFX中
class Download extends Task{
protected Object call() throws Exception {
try {
updateMessage("Establishing Connection");
DownloadHelper downloadHelper = new DownloadHelper();
downloadHelper.performTask();
return null;
} catch (IOException | ParseException ex) {
logger.error(ExceptionUtils.getStackTrace(ex));
throw ex;
}
}
}
这个任务依次调用DownloadHelper执行某些任务执行一些后台任务。
class DownloadHelper{
public DownloadHelper(){
}
public void performTask(){
----
----
}
}
有没有办法从DownloadHelper类更新任务API(updateMessage())的状态消息。
作为参数传递给封闭'Task'一个参考'DownloadHelper'构造? – trashgod
这会导致高度的耦合......我想知道是否可以使用javafx中的Property来完成 –
将引用封闭的Task的'message'属性作为参数传递给DownloadHelper构造函数? – trashgod