public static void fitRowHeight(JTable table, int row) {
        int rowHeight = table.getRowHeight();
        int columnCount = table.getColumnCount();
        for (int column = 0; column < columnCount; column++) {
            rowHeight = Math.max(rowHeight,
                    getPreferredCellSize(table, row, column,
                            table.getColumnModel().getColumn(column).getWidth(),
                            View.X_AXIS).height);
        }
        if (rowHeight != table.getRowHeight(row)) {
            table.setRowHeight(row, rowHeight);
        }
    }