title: How can I make a JTable refresh automatically from a text file?
body: <p>My code to refresh data is below but after pressing a button
  I need to run the code every time I make changes to the text file.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
      // Refresh Button
      try {
          for (int r = 0; r &lt; 100; r++) { //initializing row
              for (int c = 0; c &lt; 4; c++) { //initializing column
                  jTable1.setValueAt(null, r, c);
              }
          }
  
          BufferedReader rdfile = new BufferedReader(new FileReader("items.txt"));
  
          String[] item = new String[100];
          String[] temp;
  
          int x = 0;  //read item
          while ((item[x] = rdfile.readLine()) != null) {
              temp = item[x].split("\t");
              jTable1.setValueAt((1000 + x + 1), x, 0);
              for (int j = 1; j &lt; 4; j++) {
                  jTable1.setValueAt(temp[j - 1], x, j);
              }
  
              x++;
          }
          rdfile.close();
      } catch (IOException e) {
      }
  }
  </code></pre>