static void autoTableWidth(JTable table) { final TableColumnModel columnModel = table.getColumnModel(); for (int column = 0; column < table.getColumnCount(); column++) pcall { int width = 50; // Min width for (int row = 0; row < table.getRowCount(); row++) { TableCellRenderer renderer = table.getCellRenderer(row, column); Component comp = table.prepareRenderer(renderer, row, column); width = Math.max(comp.getPreferredSize().width +1 , width); } columnModel.getColumn(column).setPreferredWidth(width); } }