|
|
JScrollPane & the scroll speed ?
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.
|
|
0
|
|
|
|
Reply
|
Dado
|
8/30/2006 9:32:08 AM |
|
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
|
|
0
|
|
|
|
Reply
|
Bart
|
8/30/2006 10:14:34 AM
|
|
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.
|
|
0
|
|
|
|
Reply
|
Brandon
|
8/30/2006 10:46:01 PM
|
|
Brandon McCombs wrote:
> 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.
Damn, I was looking for such method in JScrollPane and in JViewport,
never occured to me to look on the scrollbars to set them.
Thanks,
Bart
|
|
0
|
|
|
|
Reply
|
Bart
|
8/31/2006 7:01:04 AM
|
|
JScrollBar.setUnitIncrement
--
Thomas A. Russ, USC/Information Sciences Institute
|
|
0
|
|
|
|
Reply
|
tar
|
9/1/2006 6:41:10 PM
|
|
|
4 Replies
233 Views
(page loaded in 0.087 seconds)
|
|
|
|
|
|
|
|
|