void () { for (int col = 0; col < getColumnCount(); col++) { DefaultTableColumnModel colModel = (DefaultTableColumnModel) getColumnModel(); TableColumn column = colModel.getColumn(col); Class colClass = getColumnClass(col); int width = 0; int rightGap = 0; if (getColumnClass(col).equals(Boolean.class)) { width = JBUIScale.scale(15); } else { rightGap = isColorColumn(col) ? JBUI.size(10, 1).width : 0; TableCellRenderer renderer; for (int row = 0; row < getRowCount(); row++) { renderer = getCellRenderer(row, col); Component comp = renderer.getTableCellRendererComponent(this, getValueAt(row, col), false, false, row, col); width = Math.max(width, comp.getPreferredSize().width); } } width += rightGap; column.setPreferredWidth(width); if (colClass.equals(Color.class) || colClass.equals(Boolean.class)) { column.setMinWidth(width); column.setMaxWidth(width); } } }