I have a "little" issue with Service usage. The code below doesn't work: text value isn't updated in HMI but its value is correct !!?
public class FilterController
{
@FXML
private TextField totalItemCount;
private final Service service = new Service() {
@Override
protected Task createTask()
{
return new Task<Void>() {
@Override protected Void call() throws Exception {
int x = (int) (Math.random() * 10000);
System.out.println("x = " + x);
try {
totalItemCount.setText(Integer.toString(x));
System.out.println("totalItemCount = " + totalItemCount.getText());
}
catch (Throwable ex)
{
System.err.println("Fail");
ex.printStackTrace();
}
return null;
}
};
}
@Override
protected void failed()
{
super.failed();
System.err.println("FAILED");
}
};
@FXML
public void handleFindProblemsEvent()
{
System.out.println("Handle Find Problems");
service.restart();
}
}
I don't have any error. Fail message isn't displayed, so I can think that job has been done but it's not the case. Is it a bug or a bad usage ? Thanks for your help.
Note: I use jre1.8.0_25