title: JavaFx Text fields are not updating on GUI
body: <p>I am trying to code a memory visualizer that will update a graph with current memory statistics and have a numerical representation just to the side of it. I have an update method that runs in a thread and should update every second. </p>
  
  <p>The issue is that none of it updates on the GUI, and in fact I believe the code stops after one iteration. I believe it has to do with some of the setText() calls because if I comment them out, then at least the graph will update.</p>
  
  <p>Here is my intialize method</p>
  
  <pre><code>@Override
      public void initialize(URL arg0, ResourceBundle arg1) {
          assert memUsage_lineChart != null : "fx:id=\"memUsage_lineChart\" was not injected: check your FXML file 'MemoryVisualization.fxml'.";
          assert text_totalMem != null : "fx:id=\"text_totalMem\" was not injected: check your FXML file 'MemoryVisualization.fxml'.";
          assert text_usedMem != null : "fx:id=\"text_usedMem\" was not injected: check your FXML file 'MemoryVisualization.fxml'.";
          assert text_availableMem != null : "fx:id=\"text_availableMem\" was not injected: check your FXML file 'MemoryVisualization.fxml'.";
          assert text_percentageUsed != null : "fx:id=\"text_percentageUsed\" was not injected: check your FXML file 'MemoryVisualization.fxml'.";
          assert text_totalRuntime != null : "fx:id=\"text_totalRuntime\" was not injected: check your FXML file 'MemoryVisualization.fxml'.";
          assert text_threadsUsed != null : "fx:id=\"text_threadsUsed\" was not injected: check your FXML file 'MemoryVisualization.fxml'.";
          assert text_version != null : "fx:id=\"text_version\" was not injected: check your FXML file 'MemoryVisualization.fxml'.";
          assert text_timeAtMaxMem != null : "fx:id=\"text_timeAtMaxMem\" was not injected: check your FXML file 'MemoryVisualization.fxml'.";
          assert text_maxMemReached != null : "fx:id=\"text_maxMemReached\" was not injected: check your FXML file 'MemoryVisualization.fxml'.";
          assert text_timeOfLastAssociation != null : "fx:id=\"text_timeOfLastAssociation\" was not injected: check your FXML file 'MemoryVisualization.fxml'.";
          assert text_something != null : "fx:id=\"text_totalRuntime\" was not injected: check your FXML file 'MemoryVisualization.fxml'.";
          assert lineChart_yAxis != null : "fx:id=\"lineChart_yAxis\" was not injected: check your FXML file 'MemoryVisualization.fxml'.";
          assert lineChart_xAxis != null : "fx:id=\"lineChart_xAxis\" was not injected: check your FXML file 'MemoryVisualization.fxml'.";
  
          runtime = 0L;
  
  
          //Initializing the ArrayLists&lt;&gt; that will contain the series of data for each possible graph
          memData = new ArrayList&lt;XYChart.Series&lt;Number,Number&gt;&gt;();       
  
          //Setting the Y-axis of the chart to change according to incoming data.
          memUsage_lineChart.getYAxis().setAutoRanging(true);
  
          //Initializes the data arrays and series for the charts 
          XYChart.Series&lt;Number, Number&gt; series_sec = new XYChart.Series&lt;Number,Number&gt;();
          memUsage_lineChart.getData().add(series_sec);
          memData.add(series_sec);
  
          //Creates a thread that continuously runs and adds data points to the displays
          ScheduledExecutorService ses = Executors.newScheduledThreadPool(1);
          ses.scheduleWithFixedDelay(new Runnable() {
              @Override
              public void run() {
                  runtime += 1000;
                  updateData();
                  try {
                      Thread.sleep(500);
                      } catch (InterruptedException e) {
                      e.printStackTrace();
                  }
              }
          }, 0, 500, TimeUnit.MILLISECONDS);
  
      }/*END OF INSTANTIATION*/
  </code></pre>
  
  <p>And here is my updateData() method</p>
  
  <pre><code>public void updateData()
  {
      //Gathers the runtime memory data from the system
      long maxFreeMemory = Runtime.getRuntime().maxMemory();
      long usableFreeMemory= Runtime.getRuntime().maxMemory()
              -Runtime.getRuntime().totalMemory()
              +Runtime.getRuntime().freeMemory();
      double usedPercent=(double)(Runtime.getRuntime().totalMemory()
              -Runtime.getRuntime().freeMemory())/Runtime.getRuntime().maxMemory();
      long usedMemory = (long)(usedPercent*maxFreeMemory);
      maxFreeMemory /= 1000000;
      usableFreeMemory /= 1000000;
      usedMemory /= 1000000;
      usedPercent *= 100;
      DecimalFormat df = new DecimalFormat("0.00");
  
      //Set the text values for the runtime statistics
      text_totalMem.textProperty().set(String.valueOf(maxFreeMemory));
      text_usedMem.textProperty().set(String.valueOf(usedMemory));
      text_availableMem.textProperty().set(String.valueOf(usableFreeMemory));
      text_percentageUsed.textProperty().set(df.format(usedPercent)+" %");
      text_totalRuntime.textProperty().set((runtime/3600000)+":"+String.format("%02d",((runtime/60000)%60))+":"+String.format("%02d",((runtime%60000)/1000)));
      text_threadsUsed.textProperty().set(String.valueOf(ManagementFactory.getThreadMXBean().getThreadCount()));
  
      //Updates the axes of the real-time graphs/charts
      if(runtime &gt;= 120000 &amp;&amp; (runtime % 12000) == 0)
      {
          lineChart_xAxis.setLowerBound(lineChart_xAxis.getLowerBound()+12);
          lineChart_xAxis.setUpperBound(lineChart_xAxis.getUpperBound()+12);
  
          for(int i=0; i&lt;12; i++)
              memData.get(0).getData().remove(0);
      }
  
      //Adds the data to the series to be placed on to the graphs/charts
      memData.get(0).getData().add(new XYChart.Data&lt;Number,Number&gt;(runtime/1000,usedMemory));
  }
  </code></pre>
  
  <p>Is there a reason my GUI gets stuck and wont update the text fields/graph when this is run? I know for a fact that the thread runs at least one iteration since the text fields are not 0 (as initialized) when the GUI pops up.</p>