I have a JTable
wrapped into a JScrollPane
. When I scroll to the top or bottom and continue to scroll, I want to be able to detect that in order to possibly load more items at the beginning or end since it is too expensive/not practical to load all items at once. The AdjustmentListener
is not fired when the JScrollPane
does not move (e.g. when it is already at the top or bottom):
scrollPane.getVerticalScrollBar().addAdjustmentListener(adjustmentEvent ->
{
int value = adjustmentEvent.getValue();
System.out.println(value); // Prints 0 e.g. when the top has been reached
});
However, I need to know when the user scrolls even though the end/start has already been reached.
How can this be done?