multithreading - JavaFX: How to make an looping thread without freezing application? -


how go making thread within javafx? i've looked around , no answers clear/want need, basicly same java's thread runnable, not conpatible javafx unless it's background task.

the basic start application class have:

public class main extends application {      private stage stage;     private anchorpane rootlayout;      @override     public void start(stage stage) {         this.stage = stage;         this.stage.settitle("main");         setlayout();     }      private void setlayout() {         try {             fxmlloader loader = new fxmlloader();             loader.setlocation(main.class.getresource("view/view.fxml"));             rootlayout = (anchorpane) loader.load();              scene scene = new scene(rootlayout);             stage.setscene(scene);             stage.show();         } catch (ioexception e) {             e.printstacktrace();         }     }      public static void main(string[] args) {         launch(args);     } } 

i need javafx thread that'll keep changing visibility of button without freezing/pausing application while it's running, how go doing this?

edit: need javafx app:

public void run(){                 while (true){                     if (button.isvisible)                     button.setvisibility(false);                     else                         button.setvisibility(true);                         thread.sleep(1000);                 }             } 


Popular posts from this blog