Here you can find the source of setTableColWidths(JTable table, int... colWidths)
public static void setTableColWidths(JTable table, int... colWidths)
//package com.java2s; //License from project: Open Source License import javax.swing.*; import javax.swing.table.*; public class Main { public static void setTableColWidths(JTable table, int... colWidths) { if ((table != null) && (colWidths != null)) { TableColumnModel tcm = table.getColumnModel(); if (tcm != null) { int n = Math.min(tcm.getColumnCount(), colWidths.length); for (int i = 0; i < n; i++) { TableColumn c = tcm.getColumn(i); if (c != null) c.setPreferredWidth(colWidths[i]); }//w w w . ja v a2 s . com } } } }