title: update few labels on javafx form
body: <p>There is simple application on JavaFx with SplitPane on Stage.<br>
  On SplitPane there are two StackPane. On Each there is one Label.<br>
  I want to update text on each Label's in cycle every per/sec. How can i do that in one Thread(one Task)? Is it real?  </p>
  
  <p>For example, i want to see text in labelUp = key of Map, and labelDw = value of Map.</p>
  
  <pre><code>package com.javarush.test.MyTry;
  import javafx.application.*;
  import javafx.concurrent.Task;
  import javafx.geometry.Orientation;
  import javafx.scene.*;
  import javafx.scene.control.Label;
  import javafx.scene.control.SplitPane;
  import javafx.stage.*;
  import javafx.scene.layout.*;
  import java.io.*;
  import java.nio.charset.Charset;
  import java.util.HashMap;
  import java.util.Map;
  
  
  public class Main extends Application
  {
  
      Map&lt;String, Integer&gt; dictionary = new HashMap&lt;&gt;();
  
      public static void main(String[] args)
      {
          launch(args);
      }
  
      public void init()
      {
          String filePath = "F:\\Java\\!Folder4Test\\test2.txt";
          try
          {
              BufferedReader reader = new BufferedReader(new FileReader(filePath));
              int cnt = 0;
              while (reader.ready())
              {
                  String line = new String(reader.readLine().getBytes(), Charset.forName("UTF-8"));
                  dictionary.put(line, cnt++);
              }
          }
          catch (FileNotFoundException e)
          {
              System.out.println("Не найден файл " + filePath);
              e.printStackTrace();
          }
          catch (IOException e)
          {
              System.out.println("Ошибка чтения файла " + filePath);
              e.printStackTrace();
          }
      }
  
      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 -&gt; {
  
              Task&lt;Void&gt; task = new Task&lt;Void&gt;()
              {
                  @Override
                  public Void call() throws Exception
                  {
                      for (Map.Entry&lt;String, Integer&gt; pair : dictionary.entrySet())
                      {
                          updateMessage(pair.getKey());
                          System.out.println(pair.getKey());
                          Thread.sleep(250);
                      }
                      return null;
                  }
              };
              task.messageProperty().addListener((obs, oldMessage, newMessage) -&gt; labelUp.setText(newMessage));
              //there i want to update text on labelDw in same time
              //task.messageProperty().addListener((a1,a2,a3)-&gt;labelDw.setText());
              new Thread(task).start();
  
          });
  
          sp.getItems().addAll(sp1, sp2);
          sp.setDividerPositions(0.5f, 0.5f);
  
  
          myStage.show();
      }
  
      public void stop()
      {
          System.out.println("B теле метода stop().");
      }
  }
  </code></pre>
  
  <p>(Sorry for my bad English)</p>