int width = table.getColumnModel().getTotalColumnWidth(); int height = table.getRowCount() * (table.getRowHeight()+table.getRowMargin()); return new Dimension(width, height);
int prefTotalColumnWidth = 0; for (int i = 0; i < table.getColumnCount(); i++) { TableColumn col = table.getColumnModel().getColumn(i); prefTotalColumnWidth += col.getPreferredWidth(); } return new Dimension(prefTotalColumnWidth, getHeight());
  public Dimension getPreferredSize(JComponent comp)   {    int width = table.getColumnModel().getTotalColumnWidth();    int height = table.getRowCount() * (table.getRowHeight()+table.getRowMargin());    return new Dimension(width, height);  }