Dimension () { Dimension base = super.getPreferredScrollableViewportSize(); int visibleRows = myVisibleRowCount; if (visibleRows <= 0) return base; if (base != null && base.height > 0) return base; boolean addExtraSpace = Registry.is("ide.preferred.scrollable.viewport.extra.space"); TableModel model = getModel(); int modelRows = model == null ? 0 : model.getRowCount(); boolean forceVisibleRowCount = Boolean.TRUE.equals(UIUtil.getClientProperty(this, FORCE_VISIBLE_ROW_COUNT_KEY)); if (!forceVisibleRowCount) { visibleRows = Math.min(modelRows, visibleRows); } int fixedWidth = base != null && base.width > 0 ? base.width : getPreferredWidth(this); Dimension size; if (modelRows == 0) { int fixedHeight = Registry.intValue("ide.preferred.scrollable.viewport.fixed.height"); if (fixedHeight <= 0) fixedHeight = UIManager.getInt("Table.rowHeight"); if (fixedHeight <= 0) fixedHeight = JBUIScale.scale(16); // scaled value from JDK size = new Dimension(fixedWidth, fixedHeight * visibleRows); if (addExtraSpace) size.height += fixedHeight / 2; } else { Rectangle rect = getCellRect(Math.min(visibleRows, modelRows) - 1, 0, true); size = new Dimension(fixedWidth, rect.y + rect.height); if (modelRows < visibleRows) { size.height += (visibleRows - modelRows) * rect.height; } else if (modelRows > visibleRows) { if (addExtraSpace) size.height += rect.height / 2; } } return size; }