0

First off, I am coming from C++ / C# and do not have a deep knowledge of java.

I made a GUI using Window Builder to handle some SmartHome stuff. I am using Paho Mqtt V3 to receive updates. Just changing f.e. a String variable in a class works fine.

Problem occurs when I try to update something within the GUI, f.e. some text of a simple text field: If I call the SetText()-method from the callback method of the Mqtt client on receive, an "Invalid thread access"-exception is thrown. I have also tried to use a callback, which results in the same error.

What is the best way to achieve an update? Surely, I could try to write an independent task only looping and delaying, waiting for f.e. a boolean set when an update is received. But this seems a bit exessive, doesn´t it?

I have deliberately refrained from posting code snippets at this point, since this is a general question, and (probably) not a direct problem in the implementation.

Thanks for your input.

Inso
  • 45
  • 4
  • [Edit](https://stackoverflow.com/posts/67039051/edit) the question to show the whole error and the code that threw it, it will be much easier for people to answer if they can see what you actually did rather than working in the abstract. – hardillb Apr 10 '21 at 21:38
  • 1
    Also does this answer your question? [Invalid Thread Access Error with Java SWT](https://stackoverflow.com/questions/5980316/invalid-thread-access-error-with-java-swt) – hardillb Apr 10 '21 at 21:39
  • @hardillb it is definitely the way to go, thank you for the hint! – Inso Apr 10 '21 at 21:47

0 Answers0