Below is a link to an article that determines whether a cell is visible. You can use this - if the cell is visible, then the row is visible. (But, of course, perhaps not the entire line if horizontal scrolling is also present.)
However, I think this will happen when the cell is wider than the viewport. To handle this case, you modify the test to check if the top / bottom border of the cell is within the vertical viewing area, but ignore the left / right side of the cell. The easiest way is to set the left and the width of the rectangle to 0. I also changed the method to take only the row index (no column index needed), and it returns trueif the table is not in the viewport, which seems to be better for your use.
public boolean isRowVisible(JTable table, int rowIndex)
{
if (!(table.getParent() instanceof JViewport)) {
return true;
}
JViewport viewport = (JViewport)table.getParent();
Rectangle rect = table.getCellRect(rowIndex, 1, true);
Point pt = viewport.getViewPosition();
rect.setLocation(rect.x-pt.x, rect.y-pt.y);
rect.setLeft(0);
rect.setWidth(1);
return new Rectangle(viewport.getExtentSize()).contains(rect);
}