7

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!

Yrlec
  • 3,401
  • 6
  • 39
  • 75
  • 2
    First of all, did you see the note in the Javadoc? "Restriction: This class is not intended to be subclassed by clients." You should definitely first try `SWT.DOUBLE_BUFFERED`, but there's no guarantees for your case. – Marko Topolnik May 24 '13 at 09:42

4 Answers4

6

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.

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
Richard Wilkes
  • 309
  • 2
  • 10
  • Thanks, I tried that but unfortunately it didn't work. I tried adding it to TextProgressBar's constructor and I also tried the parent composite. – Yrlec May 31 '13 at 21:45
  • 1
    What is triggering the redraws you're seeing? If you can identify an area where it is just being called far too often, you can wrap that with a call to .setRedraw(false) on your control, do the work that causes the rapid redraw normally, then call .setRedraw(true) at the end. – Richard Wilkes Jun 04 '13 at 20:41
1

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

Flummiboy
  • 591
  • 1
  • 7
  • 20
1

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.

berezovskyi
  • 3,133
  • 2
  • 25
  • 30
-3

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

Nitesh Verma
  • 1,795
  • 4
  • 27
  • 46