To get this working for my table I overrode setBounds
and set the preferred widths in there:
@Override
public void setBounds(int x, int y, int width, int height)
{
super.setBounds(x, y, width, height);
setPreferredColumnWidths(new double[] { 0.4, 0.4, 0.1, 0.1 });
}
I got the implementation of setPreferredColumnWidths from this article.
protected void setPreferredColumnWidths(double[] percentages)
{
Dimension tableDim = getPreferredSize();
double total = 0;
for (int i = 0; i < getColumnModel().getColumnCount(); i++)
{
total += percentages[i];
}
for (int i = 0; i < getColumnModel().getColumnCount(); i++)
{
TableColumn column = getColumnModel().getColumn(i);
column.setPreferredWidth(
(int)(tableDim.width * (percentages[i] / total)));
}
}