title: Indeterminate ProgressBar does not animate when part of a Dialog (JavaFX 10)
body: <p>When a <code>ProgressBar</code> is indeterminate it has an animation that goes back and forth. This works fine when the <code>ProgressBar</code> is part of a normal <code>Stage</code> but doesn't work when part of a <code>Dialog</code>. Instead, it seems to just sit at the start of the animation. The <code>ProgressBar</code> does, however, update properly when set to some determinate value. <em>Note: The issue does not appear in Java 8</em>.</p>
  
  <p>There are no indications of any exceptions.</p>
  
  <p>Here's an MCVE (<a href="https://i.stack.imgur.com/c4dXg.gif" rel="noreferrer">GIF of it in action</a>):</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.concurrent.Task;
  import javafx.geometry.Insets;
  import javafx.geometry.Pos;
  import javafx.scene.Node;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.control.ButtonType;
  import javafx.scene.control.Dialog;
  import javafx.scene.control.Label;
  import javafx.scene.control.ProgressBar;
  import javafx.scene.layout.HBox;
  import javafx.scene.layout.StackPane;
  import javafx.scene.layout.VBox;
  import javafx.stage.Stage;
  
  public class App extends Application {
  
      @Override
      public void start(Stage primaryStage) {
          Button detButton = new Button("Launch Determinate Task");
          detButton.setOnAction(ae -&gt; {
              ae.consume();
              createDialog(primaryStage, true)
                      .showAndWait();
          });
  
          Button indetButton = new Button("Launch Indeterminate Task");
          indetButton.setOnAction(ae -&gt; {
              ae.consume();
              createDialog(primaryStage, false)
                      .showAndWait();
          });
  
          HBox btnBox = new HBox(detButton, indetButton);
          btnBox.setSpacing(10);
          btnBox.setAlignment(Pos.CENTER);
  
          StackPane root = new StackPane(btnBox, createDummyProgressNode());
  
          Scene scene = new Scene(root, 500, 300);
          primaryStage.setScene(scene);
          primaryStage.setTitle("ProgressBar Issue");
          primaryStage.setResizable(false);
          primaryStage.show();
      }
  
      private Node createDummyProgressNode() {
          Label label = new Label("ProgressBar to show animation in Stage.");
  
          ProgressBar progressBar = new ProgressBar();
          progressBar.setMaxWidth(Double.MAX_VALUE);
  
          VBox box = new VBox(label, progressBar);
          box.setMaxHeight(VBox.USE_PREF_SIZE);
          box.setSpacing(3);
          box.setAlignment(Pos.CENTER_LEFT);
          box.setPadding(new Insets(5));
  
          StackPane.setAlignment(box, Pos.BOTTOM_CENTER);
  
          return box;
      }
  
      private Dialog&lt;?&gt; createDialog(Stage owner, boolean determinate) {
          Task&lt;?&gt; task = new BackgroundTask(determinate);
  
          Dialog&lt;?&gt; dialog = new Dialog&lt;&gt;();
          dialog.initOwner(owner);
          dialog.setTitle("Background Task - " 
                  + (determinate ? "Determinate" : "Indeterminate"));
  
          dialog.getDialogPane().setPrefWidth(300);
          dialog.getDialogPane().setContent(createDialogContent(task));
  
          dialog.getDialogPane().getButtonTypes().add(ButtonType.OK);
          dialog.getDialogPane().lookupButton(ButtonType.OK)
                  .disableProperty().bind(task.runningProperty());
  
          dialog.setOnShown(de -&gt; {
              de.consume();
              executeTask(task);
          });
  
          return dialog;
      }
  
      private Node createDialogContent(Task&lt;?&gt; task) {
          Label label = new Label();
          label.textProperty().bind(task.messageProperty());
  
          ProgressBar progressBar = new ProgressBar();
          progressBar.setMaxWidth(Double.MAX_VALUE);
          progressBar.progressProperty().bind(task.progressProperty());
  
          VBox box = new VBox(label, progressBar);
          box.setSpacing(3);
          box.setAlignment(Pos.CENTER_LEFT);
  
          return box;
      }
  
      private void executeTask(Task&lt;?&gt; task) {
          Thread thread = new Thread(task, "background-thread");
          thread.setDaemon(true);
          thread.start();
      }
  
      private static class BackgroundTask extends Task&lt;Void&gt; {
  
          private final boolean determinate;
  
          private BackgroundTask(boolean determinate) {
              this.determinate = determinate;
          }
  
          @Override
          protected Void call() throws Exception {
              final int loops = 1_000;
              for (int i = 0; i &lt;= loops; i++) {
                  updateMessage("Running... " + i);
                  Thread.sleep(1L);
                  if (determinate) {
                      updateProgress(i, loops);
                  }
              }
              updateMessage("Complete");
              updateProgress(loops, loops);
              return null;
          }
  
      }
  
  }
  </code></pre>
  
  <p>I tried this code on:</p>
  
  <ul>
  <li>JDK 1.8.0_181
  
  <ul>
  <li>Animates normally</li>
  </ul></li>
  <li>JDK 10.0.2
  
  <ul>
  <li>Fails to animate</li>
  </ul></li>
  <li>OpenJDK 11-ea+22 with OpenJFX 11-ea+18
  
  <ul>
  <li>Fails to animate</li>
  </ul></li>
  <li>OpenJDK 12-ea with OpenJFX 11-ea+18
  
  <ul>
  <li>Fails to animate</li>
  <li><em>Didn't really expect a change here since the same JavaFX version is being used</em>.</li>
  </ul></li>
  </ul>
  
  <p>All my tests were on a Windows 10 Home (version 1803) computer.</p>
  
  <p>I'm 90% certain this is some type of regression bug, but just in case...</p>
  
  <ol>
  <li>Does anyone else have this problem? Or am I doing something wrong and it's a fluke that it works on Java 8?</li>
  <li>If it is a bug does anyone know of any workarounds?</li>
  </ol>
  
  <p>I've tried things like changing the <code>Modality</code> and <code>owner</code> of the <code>Dialog</code> to no effect. It also seems to only be the <code>ProgressBar</code> as the <code>Dialog</code> can still be moved around and the message updates (i.e. the UI is not freezing).</p>
  
  <p>I haven't tried this with other animated <code>Node</code>s such as <code>ProgressIndicator</code>.</p>
  
  <p><em>P.S. I searched the Java bug database for this or similar issue but came up with nothing; I could have easily missed one, however</em>.</p>
  
  <p><em>Update: I have submitted my own bug report</em>.</p>