1
I have a For
that makes a countdown, but when I will pass the value to the Label
it only takes the last value of the loop.
This is my method:
public static void contagemRegressiva(){
System.out.println("Start");
int i=0;
for( i=10;i>=0;i--){
//label
numero[0].setText(""+i);
}
}
The result of Label
goes straight to zero.
You only need to pay attention to the use of 'Sleep' consented that it blocks the thread, so if there is no other thread the program stops responding. Depending on the GUI update speed the program may not yet display the updates, as with the pause it also does not have time to render the component. However it is possible to circumvent this by forcing the rendering of the component manually.
– utluiz