title: How to update the label box every 2 seconds in java fx?
body: <p>I'm trying to simulate a basic thermostat in an application GUI.</p>
  
  <p>I want to update a label box value every 2 secs with the new temperature value.</p>
  
  <p>For example, my intial temperature will be displayed as 68 degrees and updated to 69, to 70, etc. till 75 every 2 seconds.</p>
  
  <p>This is a piece of code I wrote in Java fx.  <code>controlpanel</code> is object of te form where the label box is present. It updates only the final value as 75. It doesnt update it every 2 secs. I have written a method pause to cause a 2 secs delay.  All labels are updated with their final values but not updated every 2 secs.  When I debug, I can see that the values are increased by one every 2 secs. This code is written in button onClick event</p>
  
  <pre><code>private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
      int i=0;
      Timer asd = new Timer(1000,null);
  
      asd.setDelay(1000);
  
      while(i &lt; 10)
      {
           jTextField1.setText(Integer.toString(i));
           i++;
  
           asd.start();
      }
   }  
  </code></pre>