TableColumn setPreferredWidth not working

Include :

table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

I had a similar problem despite trying the two other answers here. In my case, some times the width would get set correctly while other times, it would not. I found the problem was caused because I was trying to set the column widths immediately after changing my table model. I found setting the column widths inside of SwingUtilities.invokeLater() did the trick. I.E.

SwingUtilities.invokeLater(new Runnable(){

    @Override
    public void run() {
         int width = 100;  
         for (int column = 1; column < table.getColumnCount(); column++) {
             columnModel.getColumn(column).setPreferredWidth(width);
         }
    }
}

I know this is a bit late so is mostly for future readers, but I had the same problem and solved it by setting both the column's preferred width and maximum width to the same value.