title: Adding rows to JTable using a loop
body: <p>I am trying to add rows to my table using a loop. The code I have is as follows:</p>
  
  <pre><code> import javax.swing.DefaultListModel;
   import javax.swing.JFrame;
   import javax.swing.JTable;
   import javax.swing.table.DefaultTableModel;
  
  public class Test {
  
      public void testCase(){
         DefaultTableModel listTableModel;
         listTableModel = new DefaultTableModel();
         for(int i = 1; i &lt; 25 ; i++){
             String rowString = "Quiz #" + i;
             listTableModel.addRow(new Object[]{rowString, "ICON", "ICON"});
         }
  
         JTable listTable;
         listTable = new JTable(listTableModel);
         listTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
         listTable.setCellEditor(null);
         listTable.setBounds(37, 143, 397, 183);
         //listTable.getColumnModel().getColumn(0).setPreferredWidth(300);
         JFrame frame = new JFrame();
         frame.add(listTable);
         frame.setVisible(true);
         frame.pack();
     }
  
  /**
   * @param args
   */
     public static void main(String[] args) {
         // TODO Auto-generated method stub
         Test tester = new Test();
         tester.testCase();
  
     }
  
     }
  </code></pre>
  
  <p>Using a hard coded table, this method returns a functional table. hard coded looks like:</p>
  
  <pre><code> listTableModel = new DefaultTableModel( new Object[][] {{1,1,1}{2,2,2},{3,3,3}}, new String[] {"Col1, Col2, Col3});
   return listTableModel;
  </code></pre>
  
  <p>This code gives me no result. I am inserting it into a panel and it is not showing up in the panel</p>
  
  <p>I'm not sure why this is not working because all research I have done has pointed me to doing it like this... 
  any help is appreciated, thanks!</p>