I have a lab to do for my courses that consists of a trivial pursuit. After making the menu, we added buttons to switch between different views. I have a view in my application that allows you to edit questions (Json and tableView), but here is when you click on the button to open the map management view, there is a small lag that is due to creation of game cards. So, after some research on the internet, I came across the tasks in java, which I tried to apply but I am faced with an error. there she is :
There is my code :
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();
}
Thank in advance ;)