title: Deleting all the rows in a JTable
body: <p>I need to remove all the rows in my JTable.</p>
  
  <p>I have tried both of the following:</p>
  
  <pre><code>/**
   * Removes all the rows in the table
   */
  public void clearTable()
  {
      DefaultTableModel dm = (DefaultTableModel) getModel();
      dm.getDataVector().removeAllElements();
      revalidate();
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>((DefaultTableModel)table.getModel()).setNumRows(0);
  </code></pre>
  
  <p>Neither of which would remove all the rows. Any ideas?</p>