title: Update JTable with Separate Thread
body: <p>The purpose of the application is to query a table, and take that information and update a JTable.  Right now the ThreadTask() is able to query the table and obtain the information.  My question is how do I update the JTable GUI object with the information obtained from the database?  </p>
  
  <pre><code>    public class AdminManager extends JFrame {
  
          public static void main(String[] args) throws InterruptedException {
              EventQueue.invokeLater(new Runnable() {
                  @Override
                  public void run() {
                      try {
                          AdminManager frame = new AdminManager();
                          frame.setVisible(true);
                      } catch (Exception e) {
                          e.printStackTrace();
                      }
  
                  }
              });
  
              // Setup connection pool
  
              ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor();
              exec.scheduleAtFixedRate(new ThreadTask(connection), 2000, 100, TimeUnit.MILLISECONDS);
      }
          /**
           * Create the frame.
           */
          public AdminManager() {
              // Setup GUI
  
              DefaultTableModel model = new DefaultTableModel();
              model.addColumn("#");
  
  
              tableQueue = new JTable(model);
              tableQueue.getColumnModel().getColumn(0).setPreferredWidth(3);
              scrollPane.setViewportView(tableQueue);
  
          }
      class updateTable extends SwingWorker&lt;Void, String&gt; {
          @Override
          protected Void doInBackground() throws Exception {
              model.addRow(new Object[]{order_num});
              return null;
          }
  
      }
  }
  class grabData implements Runnable {
      private Connection connection;
      private DefaultTableModel model;
      private String order_num;
  
      public grabData(Connection c, DefaultTableModel m) {
           connection = c;
           model = m;
      }
  
      @Override
      public void run() {
         System.out.println("Working ... ");
         String sql = "SELECT * FROM order_queue;";
         Statement st;
         try {
             st = connection.createStatement();
             ResultSet rs = st.executeQuery(sql);
              while(rs.next()) {
                  order_num = rs.getString("order_num");
                  System.out.println(order_num);
                  updateTable.execute()
              }
         } catch (SQLException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
         }   
     }
  </code></pre>