Here you can find the source of setColumnWidth(JTable table, int... width)
public static void setColumnWidth(JTable table, int... width)
//package com.java2s; //License from project: Open Source License import javax.swing.JTable; import javax.swing.table.TableColumnModel; public class Main { public static void setColumnWidth(JTable table, int... width) { TableColumnModel columnModel = table.getColumnModel(); int length = width.length; int columnCount = table.getColumnCount(); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); for (int i = 0; i < length && i < columnCount; i++) { columnModel.getColumn(i).setPreferredWidth(width[i]); }/* ww w . jav a2 s . c o m*/ } }