title: Timeline is not running infinitely (JavaFx)
body: <p>I used to have a simple, timed (more-or-less) infinite loop:</p>
  
  <pre><code>while (!canrun) {
      do_stuff(); //simple calculation
      update_gui(); //updates some labels
      Thread.sleep(waittime);
  }
  </code></pre>
  
  <p>Which, naturally freezes the JavaFX-Application until it is finished with all calculations (canrun is set to false).</p>
  
  <p>I replaced it with a timeline:</p>
  
  <pre><code>    event = new EventHandler&lt;ActionEvent&gt;() {
          @Override
          public void handle(ActionEvent actionEvent) {
              do_stuff();
              update_gui();
          }
      };
      keyframe = new KeyFrame(Duration.millis(waittime), event);
      timeline = new Timeline(Timeline.INDEFINITE, keyframe);
  </code></pre>
  
  <p>do_stuff() looks like this:</p>
  
  <pre><code>public void do_stuff() {
      do_the_actual_stuff();
      if (stuff_finished) timeline.stop();
  }
  </code></pre>
  
  <p>(waittime is here a number between 1 and 1000 (ms)).
  On Buttonclick I start it with timeline.play(), and in do_stuff() I stop it when the calculations are done with timeline.stop().</p>
  
  <p>I also have a function to change the waittime (even when it runs):</p>
  
  <pre><code>public void changewaittime() {
  
      if (!(timeline.getStatus() == Animation.Status.RUNNING)) {
          keyframe = new KeyFrame(Duration.millis(waittime), event);
          timeline = new Timeline(Timeline.INDEFINITE, keyframe);
      } else {
          timeline.stop();
          keyframe = new KeyFrame(Duration.millis(waittime), event);
          timeline = new Timeline(Timeline.INDEFINITE, keyframe);
          timeline.play();
      }
  }
  </code></pre>
  
  <p>And now my problem is, the Timeline only runs once, and not continuously, it doesn't even enter do_stuff() again, only if I call timeline.play() again. Even directly calling timeline.setCycleCount(Timeline.INDEFINITE) doesn't help.</p>
  
  <p>Anything I missed?</p>
  
  <p>Edit: I was unable to find my mistake, so I rewrote the complete GUI and now it is working.</p>