Re: JScrollPane & the scroll speed ?



Bart Cremers wrote:
Dado wrote:
Is it difficult to speed up the scroll of JScrollPane content ? It is too
slow for me, if I use the mouse wheel or arrows of a slider.

You'll have to override the scrollable increment methods in your
scrollable component (the thing you add to the scrollpane). Following
code makes scrolling in a JEditorPane really slow. The numeric values
are the number of pixels the view should be moved for a click on the
arrow or in the gray area of the scrollbar.

JEditorPane ePane = new JEditorPane(url) {
public int getScrollableUnitIncrement(Rectangle visibleRect, int
orientation, int direction) {
return 1;
}

public int getScrollableBlockIncrement(Rectangle visibleRect, int
orientation, int direction) {
return 2;
}
};

Regards,

Bart


Why override when he can simply do the following to the scrollpane itself?

myScrollPane.getHorizontalScrollBar().setUnitIncrement(10);
myScrollPane.getVerticalScrollBar().setUnitIncrement(10);

Those work fine for me when having a jlist in a scrollpane.
.



Relevant Pages

  • Re: JScrollPane & the scroll speed ?
    ... if I use the mouse wheel or arrows of a slider. ... scrollable component (the thing you add to the scrollpane). ... public int getScrollableUnitIncrement(Rectangle visibleRect, int ... orientation, int direction) { ...
    (comp.lang.java.gui)
  • Re: JScrollPane & the scroll speed ?
    ... You'll have to override the scrollable increment methods in your ... public int getScrollableUnitIncrement(Rectangle visibleRect, int ... Why override when he can simply do the following to the scrollpane itself? ...
    (comp.lang.java.gui)