private static int calcMaxWidth(@NotNull JTable table) {
    int colsNum = table.getColumnModel().getColumnCount();

    int totalWidth = 0;
    for (int col = 0; col < colsNum; col++) {
      TableColumn column = table.getColumnModel().getColumn(col);
      int preferred = column.getPreferredWidth();
      int width = Math.max(preferred, columnMaxWidth(table, col));
      totalWidth += width;
      column.setMinWidth(Math.min(ShowUsagesTable.MIN_COLUMN_WIDTH, width));
      column.setMaxWidth(width);
      column.setWidth(width);
      column.setPreferredWidth(width);
    }
    table.getColumnModel().getColumn(colsNum - 1).setMaxWidth(Integer.MAX_VALUE); //last column should grow for the rest of the table width

    return totalWidth;
  }
private static int calcMaxWidth(@NotNull JTable table)