I'm using a SWT ScrolledComposite but when I scroll in Windows I get some tearing / flickering if I scroll to fast. What can I do to double buffer or reduce this effect, or what can I do to override the default scrolling functionality and make it scroll more smoothly? There's text boxes in the scrolling area so I don't think a canvas would work.
Asked
Active
Viewed 1,746 times
1 Answers
0
The trick is to play with delay and use one-pixel scrolling.
Here are parts of the code how I actually do that:
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;//ms
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 that helps!

Vladimir
- 4,782
- 7
- 35
- 56