Here you can find the source of getColumnWidths(JTable tbl)
public static List<Integer> getColumnWidths(JTable tbl)
//package com.java2s; //it under the terms of the GNU Affero General Public License as published by import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import javax.swing.JTable; import javax.swing.table.TableColumn; public class Main { public static List<Integer> getColumnWidths(JTable tbl) { final List<Integer> result = new ArrayList<Integer>(); final Enumeration<TableColumn> enumeration = tbl.getColumnModel().getColumns(); while (enumeration.hasMoreElements()) { final TableColumn column = enumeration.nextElement(); result.add(column.getWidth()); }/*w w w.j a v a2s .com*/ return result; } }