tags:

views:

34

answers:

3

How can I move programmatically a JScrollBar based on amount of wheel mouse rotation?

A: 

The type of scrolling that occurs, either WHEEL_UNIT_SCROLL or WHEEL_BLOCK_SCROLL, is platform dependent. The amount that the mouse wheel scrolls is also platform dependent. Both the type and amount of scrolling can be set via the mouse control panel for the platform.control panel for the platform.

From here

johnbk
A: 

Mouse Wheel Listener

Edit:

myScrollpane.getViewPort().setPosition(new Point(x,y));
org.life.java
Yes but what methods of a JScrollBar I must use to update it?
xdevel2000
@xdevel2000 edited
org.life.java
+1  A: 

you can use the setValue method of the JScrollBar to set the position of the scroll bar.

Alternatively you can use the methods of the Model behind the JScrollBar; example: bar.getModel().setValue(position).

You can use the getMinimum and getmaximum methods of the JScrollBar (or from the Model) to check the valid values for setValue.

The Javadoc should help more: JScrollBar

Carlos Heuberger