1

I am trying to set a BitmapField's image using the setImage() method. It works fine, but when I try to do it on a thread it throws a IllegalStateException and it doesn't work.

Is there any workaround for this?

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
Edu
  • 13
  • 2

1 Answers1

2

You need to do the update in the event dispatch thread (or at least get the lock). The easiest way to do it is with the following code pattern:

UiApplication.getUiApplication().invokeLater(new Runnable() {
    public void run() {
        ... your code here ...
    }
});
Marc Novakowski
  • 44,628
  • 11
  • 58
  • 63