title: JavaFX: Platform.runLater(task) not recognized for task = new FutureTask<>(new Runnable() {....}?
body: <p>Over the last two weeks I have studied 10 different ways to avoid problems with <code>sleep()</code>.  The concept of running a block of code on the UI Thread that cannot be interrupted seems the most practical.  So I have proceeded to create a <code>FutureTask&lt;Void&gt;</code> object that contains the code not to be interrupted before completed.  The code in <code>for</code> loops, <code>pixelArray[r][c].setFill(color)</code> sets the new colors for <code>Circle</code> Objects in a <code>Grid Array</code> that's 32x64.  This has always failed to display the colors when just <code>sleep(5000)</code> is invoked between the pixel art files, <code>FileChooser</code> selects and assigns to <code>List&lt;File&gt; selectedFiles</code>.  Unfortunately the following code will not compile because <code>runLater</code> in the <code>linePlatform.runLater(diplayFileTask);</code> can't be resolved in the following code:</p>
  
  <pre><code>public class PlayPlaylist{
  
  public static List&lt;File&gt; selectedFiles;
  
  public static void play() throws ExecutionException {
  
      FileChooser fileChooser = new FileChooser();
      fileChooser.setInitialDirectory(new File("C:\\ProgramData\\L1 Art Files\\"));
      fileChooser.setTitle("Play One or More Pixel Art Files");
      List&lt;File&gt; selectedFiles = fileChooser.showOpenMultipleDialog(null);
      for (File selectedFile : selectedFiles) {
          try {
              displayFile(selectedFile.getPath());
          } catch (IOException | InterruptedException e) {
              e.printStackTrace();
          }
      }
  }
  
  public static void displayFile( String pathName) throws IOException, InterruptedException, ExecutionException {
  
      FutureTask&lt;Void&gt; displayFileTask = new FutureTask&lt;&gt;(new Runnable() {
          @Override
          public void run() {
  
              path = Paths.get(pathName);
              try {
                  pixelByteArray = Files.readAllBytes(path);
              } catch (IOException e) {
                  e.printStackTrace();
              }
  
  
              int cnt = 0;
              for (int r = 0; r &lt; row; r++) {
                  for (int c = 0; c &lt; col; c++) {
                      //int i = r * col + c;
                      //System.out.println("\nr = " + r + "  c = " + c);
  
                      String hexRGB = String.format("#%02X%02X%02X",
                              pixelByteArray[cnt++],                  //red
                              pixelByteArray[cnt++],                  //green
                              pixelByteArray[cnt++]);                 //blue
  
                      Color color = Color.valueOf(hexRGB);
                      //System.out.println("\ncolor is " + color);
  
                      pixelArray[r][c].setFill(color);
                  }
              }
              String fileName = path.getFileName().toString();
              window.setTitle(MessageFormat.format("Pixel Array {0} x {1}    File:  {2}", Integer.toString(row), Integer.toString(col), fileName));
          }
      }, null); // displayFile
      Platform.runLater(displayFileTask);
      displayFileTask.get();
      sleep(5000);
  }
  </code></pre>
  
  <p>I've followed the example(s) closely in Stack Overflow and fail to see the problem(s).</p>
  
  <p>I have more details on past attempts posted on Stack Overflow at: <a href="https://stackoverflow.com/questions/34003813/wait-sleep-not-working-as-thought?noredirect=1#comment55764295_34003813">Wait() &amp; Sleep() Not Working As Thought</a>.</p>
  
  <p>I also have the two UI windows posted on the web at: <a href="https://virtualartsite.wordpress.com/" rel="nofollow noreferrer">Virtual Art</a>.  I think the pixel art shown in the Pixel Array window clarifies the goal of creating a user-defined slide show.</p>
  
  <p>Can anyone correct my errors?  Do you think my <code>sleep(5000)</code> is in the best location?</p>
  
  <p><strong>Answering James_D's questions.</strong>  This is my best solution to your answer at my first post, <a href="https://stackoverflow.com/questions/34003813/wait-sleep-not-working-as-thought?noredirect=1#comment55764295_34003813">Wait() &amp; Sleep() Not Working As Thought</a>.  I was actually following your logic and code posted at, <a href="https://stackoverflow.com/questions/30569709/java-thread-immediately-update-ui">java thread immediately update UI</a>.</p>
  
  <p>I save and display pixel art files that are 32x64.  You can see an example posted on the <a href="https://virtualartsite.wordpress.com/" rel="nofollow noreferrer">Virtual Art</a> website.  I thought it would be straight forward to create a slide show under <code>Playlist</code>, click <code>Play</code>.  I would use the same class and <code>OpenFile(pathname)</code> method in a for loop to display each file selected and placed in the <code>ArrayList&lt;&gt;</code> but pause by putting <code>Thread.sleep(5000)</code> in the loop.</p>
  
  <p>As you pointed out, this doesn't work, as I best understand, because the <code>Thread.sleep(5000)</code> interrupts the UI Thread causing a "skip" over of just the display code of all the files looped through.  But last pixel art file  <strong>will appear</strong> after 5 secs.</p>
  
  <p>I thought your answer in the post referenced above applied: You create a block of code using <code>FutureTask&lt;Void&gt;</code> and <code>Platform.runLater&lt;task&gt;</code> that can't be interrupted until completed. I thought the <code>FutureTask&lt;Void&gt;</code> runs on the UI Thread and would finish displaying the pixel art file before <code>Thread.sleep(5000)</code> could interrupt.</p>
  
  <p>At 68 and retired, I'm new to JavaFX and trying to develop this RGB LED product that can be programmed with a basic pixel editor.  Learning JavaFX is a real challenge for me, <strong>thanks for your time and patience</strong>. </p>