Non-smooth JScrollPane scrolling

hi

When I scroll a JScrollPane with the mousewheel it doesn’t make the viewport jump by the next unit-increment of the vertical scrollbar like it does when I press on the up or down buttons, but makes the viewport move smoothly by that amount. The problem is, that the contents of my pane are pretty complex to draw, which make the scrolling pretty jerky. Is there a way to avoid that smoothness and tell the scrollpane to hard-scroll when scrolling with the wheel?

Marvin

Hi,

Hope this is what you need:


scrollpane.getVerticalScrollBar().setUnitIncrement( pixels );

Thanks for the reply. No, this is not, what I need. I have already set it it 20. But when I scroll with the wheel, the pane doesn’t simply jump from the current scroll value to +20, but kind of slides. So all (or many) of the steps between are drawn, too. This is, what I want to avoid.

Marvin

Try to use this:

scrollpane.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE);
// or maybe JViewport.SIMPLE_SCROLL_MODE

Yeehaa! That helped. Thanks a lot, man.

Marvin