When a user clicks a button on the UI I want the button to be hidden and then I want a background task to launch that does a bunch of stuff.
EDIT: How do I ensure that the button is hidden before any other blocking task starts?
class startTask implements Callable<Void>{
@Override
public Void call() {
//.....Do a bunch of stuff.....
return null;
}
}
public void hitTheButton() throws ExecutionException, InterruptedException {
hideTheButton();
//this only happens first IF i remove the .get()
StartTask startTask = new StartTask();
ExecutorService ex = Executors.newSingleThreadExecutor();
Future<?> exFuture = ex.submit(startSyncTask);
exFuture.get();
//.... Now we can continue with the program....
}
public void hideThebutton(){
FadeTransition ft = new FadeTransition(Duration.millis(10), myButton);
ft.setFromValue(1);
ft.setToValue(0);
ft.setCycleCount(1);
ft.setAutoReverse(false);
}
I have also tried putting .isDone()
in a while loop to no avail.
I understand that the UI is blocked by the .get() but why wouldn't the hide method be completed before I even instantiate the Executor??