int (@NotNull JTable table) { JTableHeader header = table.getTableHeader(); if (header != null) { Dimension size = header.getPreferredSize(); if (size != null && size.width > 0) return size.width; } int width = 0; TableColumnModel model = table.getColumnModel(); if (model != null) { for (int i = 0; i < model.getColumnCount(); i++) { TableColumn column = model.getColumn(i); if (column != null) width += Math.max(column.getWidth(), column.getPreferredWidth()); } } return width > 0 ? width : JBUI.scale(100); }