我有一个实验室可以为我的课程做一些琐碎的追求。制作菜单后,我们添加了按钮以在不同视图之间切换。我的应用程序中有一个视图允许您编辑问题(Json和tableView),但是当您单击按钮打开地图管理视图时,由于创建游戏卡而存在一个小的延迟。因此,经过对互联网的一些研究,我遇到了java中的任务,我尝试应用但我遇到了一个错误。 她在那里:
有我的代码:
public Deck getDeckCreate() {
if(newDeck == null) {
newDeck = new Deck();
//Read Json File
Gson gson = new Gson();
String res = JsonTransform.readFromFile("json.json", false);
newDeck = gson.fromJson(res, Deck.class);
//Read Json File
}
return newDeck;
}
public void createDeckTask() {
//Task for computing the Panels:
Task<ObservableList<Question>> task = new Task<ObservableList<Question>>() {
@Override
protected ObservableList<Question> call() throws Exception {
return getDeck();
}
};
// make sure the result will be assigned to the items property
// on the application thread as soon as it's ready
view.itemsProperty().bind(task.valueProperty());
new Thread(task).start();
}
public GestionAdmin() {
createDeckTask();
createTable();
}
提前感谢;)