I created JPanel with implemented Scrollable
interface and overrided method getScrollableBlockIncrement
.
I placed JPanel into JScrollPane.
And JPanel contains several components with same height. This height is the unitIncrement.
Now, when I click on arrow on the vertical scrollbar, viewport moves by unitIncrement.
But, when I move knob with mouse, viewport moves by pixels.
How to make viewport to move only by unitIncrement?
Update:
Knob is the middle button on scrollbar, on track, to drag it. As shown there How a Scroll Pane Works
I want viewport moves only by unitIncrement in any way. Also when I press left mouse button on knob and drag it. The example behaviour: intellisense in Eclipse.
Update 2:
I tried
myJScrollPane.getVerticalScrollBar().setUnitIncrement(16);
And didn't get desired behaviour.
When I debugged code, I found that parameter unitIncrement is discarded when I drag the knob.
Update 3:
Couldn't find suitable solution with JScrollPane and wrote custom scroll pane.