Thank you Chris, that did the trick!
El 12/07/11 00:48, Chris Bartlett escribió:
Edgar,
Search the mailing list archives for previous posts that refer to
'ApplicationContext.queueCallback(Runnable)'
apache-pivot-users.399431.n3.nabble.com
apache-pivot-developers.417237.n3.nabble.com
It is used to queue a Runnable to be executed on the UI thread. If wrap your
call to label.setText() in a Runnable, and execute with queueCallback(), you
should see the label update properly.
Chris
-----Original Message-----
From: Edgar Merino<[email protected]>
Sent: 12 July 2011 08:07
To: [email protected]
Subject: Task countdown and Labels
Hello, I'm trying to implement a simple countdown animation using a Task
and a Label: when the task is executed, it goes through a loop that
repeats five times and does two things here: update the label with the
current counter and sleep a second. However, sometimes I don't see the
label updating until some processing on the application is finished, is
there a way to force the application to wait for the label to be updated
first before trying to assign a different value to its text property?
Here's some sample code:
public class CountdownTask extends Task {
private Label label;
public CountdownTask(Label label) {
this.label = label;
}
public void execute() {
for (int i = 5; i>= 0; i--) {
label.setText(i+1);
Thread.sleep(1000);
}
}
}
I've tried running this both sync and async and I always get the same
result.
Thanks in advance,
Edgar Merino