So far I know how to get a particular row at a point using the JScrollPane's JViewPort object.
scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
JViewport viewport = scrollPane.getViewport();
Point p = viewport.getViewPosition();
int rowIndex = getLogsTable().rowAtPoint(p);
System.out.println("Minimum Y: " + viewport.getViewRect().getMinY());
System.out.println("Min row: " + getLogsTable().rowAtPoint(new Point(0, (int) viewport.getViewRect().getMinY())));
System.out.println("Maximum Y: " + viewport.getViewRect().getMaxY());
System.out.println("Max row: " + getLogsTable().rowAtPoint(new Point(0, (int) viewport.getViewRect().getMaxY())));
}
});
I am having a tough time figuring out how to get all the rows between the JViewport.getMinimumY() and JViewport.getMaximumY(). Is there a way to gather all row items between those two viewport points or is there any way to just get all rows in the JScrollPane view?
Based on @dic19's comment, I used that snippet of code, and it worked. I just added an extra variable to handle retrieving the last row index number.