int (@NotNull JTable table, int maximumHiddenPart) { Rectangle visibleRect = table.getVisibleRect(); Point leadingPoint = getLeadingPoint(table, visibleRect); int row = table.rowAtPoint(leadingPoint); int column = table.columnAtPoint(leadingPoint); if (leadingPoint.y - table.getCellRect(row, column, true).getY() <= maximumHiddenPart) { return row; } else { return Math.min(row + 1, table.getRowCount() - 1); // just in case } }