title: Threads and jtable
body: <p>I have a problem with jtable. </p>
  
  <p>I have a number of threads and each of them have to add a row to the jTable, but the table remains empty. I'm working with netbeans, the graphics are totally separate from the logic. Can someone help me, please?</p>
  
  <hr>
  
  <p>this is the code that i use for adding a row</p>
  
  <p><strong>MainGui.java</strong></p>
  
  <pre><code>public void addToTable(String from, String to, int request, int response, String timeElapsed) {
      Object [][] temp = new Object [data.length + 1][5];
  
      for (int i = 0; i &lt; data.length; i++) {
          for (int j = 0; j &lt; 5; j++) {
              temp[i][j] = data[i][j];
          }
      }
  
      temp[data.length][0] = from;
      temp[data.length][1] = to;
      temp[data.length][2] = request;
      temp[data.length][3] = response;
      temp[data.length][4] = timeElapsed;
  
      data = temp;
      table.setModel(new DefaultTableModel(data, columnName));
  }
  </code></pre>
  
  <p><strong>MyThread.java</strong></p>
  
  <pre><code>public void run() {
      try {
          MainGui mg = new MainGui();
          mg.addtotable("null", "null", 0, 0, "null");
      } catch (Exception e) {
      }
  </code></pre>