czesc! chcialbym was spytac jak to jest, ze zmieniam tekst Labelu a mimo to on pozostaje w starej postaci. Chcialbym uzyskac efekt liczenia w dol. Stad tez zrobilem cos takiego:
@FXML
private Label timeCounterLabel;
private void countTimeToStart(){
Runnable runnable = new Counter(timeCounterLabel);
new Thread(runnable).start();
}
class Counter implements Runnable{
private Label label;
public Counter(Label label){
this.label = label;
}
public void run() {
try {
for (int i = 3; i > 0; i--) {
label.setText(i + "...");
Thread.sleep(1000);
}
label.setText("Start!");
Thread.sleep(1000);
label.setVisible(false);
}catch (InterruptedException e){}
}
}
jednak kompletnie nic się nie dzieje. doczytałem, że do odświeżania UI w JavieFX jest stosowane Platform.runlater(). jednak po zmianie kodu nadal nic się nie dzieje. mam wrażenie, że zmiany blokuje Thread.sleep(). Tylko jak? i dlaczego?