The trick is to play with a delay and use one-pixel scrolling.
Here is a piece of code, as I actually do it:
public void scrollOnePixelUp() {
scrolledComposite.getContent().setLocation(0, scrolledComposite.getContent().getLocation().y - 1);
}
public void scrollOnePixelDown() {
scrolledComposite.getContent().setLocation(0, scrolledComposite.getContent().getLocation().y + 1);
}
private int pixelScrollDelay = 50;
scrollingThread = new Thread() {
public void run() {
doScrolling = true;
int i = 0;
while((i < scrollLength) && running && doScrolling) {
i++;
if (d.isDisposed())
return;
d.asyncExec(new Runnable() {
public void run() {
if (scrollUp)
scrollOnePixelUp();
else
scrollOnePixelDown();
}
});
try {
sleep(pixelScrollDelay);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
doScrolling = false;
}
};
Hope this helps!
source
share