Yrlec
Yrlec

Reputation: 3458

Getting rid of flicker in SWT

We are using a the following class to show a progress-bar in our Java application: TextProgressBar

Unfortunately we are having some problems with flickering when using that (Win 7, Java 7). Do you have any tips on how we can avoid that? Can we somehow repaint it less frequently, use double-buffering or something else? Any tips are greatly appreciated!

Upvotes: 7

Views: 2362

Answers (4)

Richard Wilkes
Richard Wilkes

Reputation: 307

First, try passing SWT.DOUBLE_BUFFERED in for the style parameter on construction. If that fails to improve the situation, move up the parent chain and add SWT.DOUBLE_BUFFERED to their constructor call instead.

If you don't have control over the parent, then you'll likely need to wrap your control in another Composite that has this flag enabled.

Upvotes: 6

berezovskyi
berezovskyi

Reputation: 3511

Disclaimer: I know that the question asks specifically about the TextProgressBar. However, I believe that many views of this question are not limited to this widget.

I had a problem with the flickering of the Text widget, which I could not resolve neither by using the SWT.DOUBLE_BUFFERED style, nor by wrapping it with the Composite, nor by applying any combination of them.

Finally, I was able to resolve this problem by simply changing the widget type from Text to StyledText. There is no flicker even without the SWT.DOUBLE_BUFFERED style and without the Composite wrapper.

Hope this will help someone who was attracted by the broad title of this question.

Upvotes: 1

Flummiboy
Flummiboy

Reputation: 592

try SWT.NO_BACKGROUND first, and if not use SWT.DOUBLE_BUFFERED. Do not use both at the same time, because there is no point. See the discussion

Upvotes: 1

Nitesh Verma
Nitesh Verma

Reputation: 1815

you can try delaying the time with thread.sleep(). It worked for me when i had the same problem when working with jTables

Upvotes: -3

Related Questions