Dimension () { Dimension size = super.getPreferredSize(); if (myAdditionalRowsCount == 0) return size; int additionalHeight = myAdditionalRowsCount * getRowHeight(); JViewport viewport = ComponentUtil.getViewport(this); int visibleAreaHeight = viewport == null ? 0 : viewport.getHeight(); if (visibleAreaHeight > 0) additionalHeight = Math.min(visibleAreaHeight - rowHeight, additionalHeight); return new Dimension(size.width, size.height + additionalHeight); }