Repaint() and AsyncUpdater



Can you please explain how the messaging works?

I am a little confused on repaint() calls. When I call repaint(), I understand they go to main message loop of OS, and when I use AsyncUpdater, the message are delivered on the timer thread? How many threads are you using by default?

I had a previous problem, when I tried to update a Label from a IP thread, I had no success when a PopUp menu was shown, I had to use AsyncUpdater. The problem was solved but I didn’t quite figure out the exact mechanism of the solution.

My main problem is: I want to update the display properties of a component. Any number of properties (Font, Colours, etc.) may cause a repaint() to be called. If I call repaint() for each property will the repaints will be reduced to one paint call or will the paint event get called for each repaint()?

At ScrollBar you are using AsyncUpdater for Update events, and this made me wonder?


The timer thread is used internally, and doesn’t call any user code. All timers, async updaters, and any other event callbacks all happen on the main message thread.

Calling UI code from any other thread is very dangerous unless you use a MessageManagerLock. More info on that is in the comments for it.

And yes, of course all repaint events get coalesced, so don’t worry about that. Scrollbars use the async updater for a different reason.