Here you can find the source of calculateColumnWidth_1(JTable table, int pos)
public static int calculateColumnWidth_1(JTable table, int pos)
//package com.java2s; import javax.swing.JTable; import javax.swing.table.TableColumn; public class Main { public static int calculateColumnWidth_1(JTable table, int pos) { for (int ii = 0; ii < table.getColumnModel().getColumnCount(); ii++) { TableColumn col = table.getColumnModel().getColumn(ii); if (ii == pos) { return col.getHeaderValue().toString().getBytes().length * 10; }//from www . j av a2s . co m } throw new RuntimeException("error!!"); } }