java - How can I make the content of a Label change after one second using JavaFX? -


i'm trying make splash screen, need words stays appearing. used o thread, don't know how can make loop label appear , after 1 second changes.

package br.com.codeking.zarsystem.splash;  import javafx.concurrent.task; import javafx.concurrent.workerstateevent; import javafx.event.eventhandler; import javafx.fxml.fxml; import javafx.scene.control.label;  public class controllersplash {      @fxml     label lblloading;        @fxml     private void initialize() {         system.out.println("app start");          lblloading.setstyle("-fx-font-size: 16px;" + "-fx-font-family: ubuntu;"                 + " -fx-text-fill: white;"); 

here i've tried repeat step 10 times, don't works

        while (i <= 10) {              task<void> sleeper = new task<void>() {                  @override                 protected void call() throws exception {                         try {                             thread.sleep(1500);                          } catch (exception e) {                             e.printstacktrace();                         }                      return null;                 }             };              sleeper.setonsucceeded(new eventhandler<workerstateevent>() {                 @override                 public void handle(workerstateevent event) {                      lblloading.settext("to change " + i);                 }             });              new thread(sleeper).run();                  i++;         }     }  } 

i can't execute in loop? don't have idea have do... i'm looking for, nothing helps me. can you? thank much!

you can use pausetransition:

 pausetransition pausetransition = new pausetransition(duration.seconds(1));  pausetransition.setonfinished(e -> lblloading.settext("complete"));  pausetransition.play(); 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo