change the scroll speed of a scroll pane?

K

Kevin

One question about JScrollPane:

we can use:
jScrollPane.getHorizontalScrollBar().setUnitIncrement(60);
jScrollPane.getHorizontalScrollBar().setBlockIncrement(180);
to set how much space/pixel to scroll when user click on the scroll
bar.

However, how about if the user presses the arrow keys on the keyboard
instead of using the mouse??? I find in that way, the scroll pane
scrolls very slowly. How to set its speed (amount of pixel to scroll)
for the scroll event from keyword arrow keys?

Thanks a lot. :)
 
R

Roland

One question about JScrollPane:

we can use:
jScrollPane.getHorizontalScrollBar().setUnitIncrement(60);
jScrollPane.getHorizontalScrollBar().setBlockIncrement(180);
to set how much space/pixel to scroll when user click on the scroll
bar.

However, how about if the user presses the arrow keys on the keyboard
instead of using the mouse??? I find in that way, the scroll pane
scrolls very slowly. How to set its speed (amount of pixel to scroll)
for the scroll event from keyword arrow keys?

Thanks a lot. :)
Which component do you have inside the scrollpane? If this component
implements javax.swing.Scrollable you can control the block and unit
increments (getScrollableUnitIncrement(Rectangle,int,int)).
A number of components already implement this interface, so have a look
at the source of getScrollableUnitIncrement in JList, JTable, JTree or
JTextComponent, for instance.
HTH,
--
Regards,

Roland de Ruiter
___ ___
/__/ w_/ /__/
/ \ /_/ / \
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top