title: How to avoid Not on FX application thread; currentThread = JavaFX Application Thread error?
body: <p>Below code snippets is giving me error <code>Not on FX application thread; currentThread</code>=<code>JavaFX</code> <code>Application Thread</code>.This application was working fine in java 1.7 but when i moved it to fx8 it is now giving error. when I start the application on my 1st attempt it is working as intended .But after closing the stage and opening it again it is not working. </p>
  
  <p>The error is also ambiguous <code>Not On fx application thread  and current thread- javafx</code> <code>application thread</code>.What  did it mean by not on fx application thread if the current thread is a fx application thread. </p>
  
  <pre class="lang-java prettyprint-override"><code>progressDialog = createProgressDialog(service);
  progressDialog.show();
  progressDialog.setOnCloseRequest(new EventHandler&lt;WindowEvent&gt;() {
      @Override
      public void handle(WindowEvent event) {
          // if (service.isRunning()) {
          // service.cancel();
          progressDialog.close();
          // }
      }
  });
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>@SuppressWarnings("unchecked")
  private Stage createProgressDialog(final Service&lt;IStatus&gt; service) {
      stage = new Stage();
  
      URL url = FileLocator.find(Activator.getDefault().getBundle(),
      new Path("icons/xxx_16x16.png"), null); //$NON-NLS-1$
      stage.getIcons().add(new Image(url.getFile()));
      stage.setTitle("Downloading ..."); //$NON-NLS-1$
      // Creating StackPane
      stage.initModality(Modality.WINDOW_MODAL);
  }
  </code></pre>