There is some JavaFx application with SplitPane on stage.
On the SplitPane there are 2 labels.
How in a cycle to update the values of Labels on a form with a delay of 1 second?
I found this solution
public void start(Stage myStage) { myStage.setTitle("JavaFXSkeleton."); SplitPane sp = new SplitPane(); sp.setOrientation(Orientation.VERTICAL); Label labelUp = new Label("test"); Label labelDw = new Label("тест"); Scene scene = new Scene(sp,800,800); myStage.setScene(scene); final StackPane sp1 = new StackPane(); sp1.getChildren().add(labelUp); final StackPane sp2 = new StackPane(); sp2.getChildren().add(labelDw); sp.setOnMouseClicked(event -> { Task<Void> task = new Task<Void>() { @Override public Void call() throws Exception { for (Map.Entry<String, String> pair : dictionary.entrySet()) { String key = pair.getKey(); //ключ String value = pair.getValue(); //значение updateMessage(pair.getKey()); System.out.println(key + ":" + value); Thread.sleep(250); } return null ; } }; task.messageProperty().addListener((obs, oldMessage, newMessage) -> labelDw.setText(newMessage)); task.messageProperty().addListener((obs, oldMessage, newMessage) -> labelUp.setText(newMessage)); new Thread(task).start(); }); sp.getItems().addAll(sp1, sp2); sp.setDividerPositions(0.5f, 0.5f); // показать подмостки и сцену на них myStage.show(); } The problem with this solution is that it updates the values in the same Label. How to update 2xLabel values in one thread?