Hi All, I have a particularly nasty problem with a ScrollBar behavior.
I have an application that shows 100 rows to start off and then check the actual row count in the background. The problem occurs when the user is dragging the scrollbar and the row count is updated.
The user starts dragging the vertical scrollbar bubble when there are only 100 rows in the table. The scrollbar is at 50% (= 50th row, say). In the meantime the rowcount in the UI is updated to 60,000,000 (say). The user is still continuing to drag without letting go of the mouse button. The viewport jumps to the 30,000,000 row. Basically, the scrollbar bubble is jumping to relative position (50%) rather than an absolute position (50th row).
Jumping to the 30,000,000th is a very expensive operation for my application and should be avoided unless the user wants to jump.
Is there anyway I can cancel the user gesture before modifying the row count? Any other way I can make sure the scrollbar bubble doesn't jump if the user doesn't let go of the mouse?
60 million rows, and you're concerned about the scrollbar? How may years would it take me to scroll to the end if I'm looking for something?
Anyway, untested, perhaps you could add a mouseListener to the scrollbar, and in mousePressed() get scrollBar's getMaximum() and table's getRowCount() (these should be a values relative to the records in the table at that time)
a bit of arithmetic to determine the relative row, and in mouseReleased() you have scrollRectToVisible('the row').