You could do the following:
AdjustmentClass adj = new AdjustmentClass();
scrollPane.getHorizontalScrollBar().addAdjustmentListener(adj);
scrollPane.getVerticalScrollBar().addAdjustmentListener(adj);
And in your AdjustmentClass do the following:
public class AdjustmentClass implements AdjustmentListener {
public void adjustmentValueChanged(AdjustmentEvent adjustmentEvent) {
// Implement your custom code here
}
}
To get orientation of the event do:
adjustmentEvent.getAdjustable().getOrientation();
You find the orientation constants in:
AdjustmentEvent.UNIT_INCREMENT
AdjustmentEvent.BLOCK_INCREMENT
etc. etc.
To check if user is dragging the scroll-bar knob do:
adjustmentEvent.getValueIsAdjusting()
There are i few more, check the API for more info if you need.
Happy coding!