• Post Reply Bookmark Topic Watch Topic
  • New Topic

Updating Gfx on seperate Swing thread  RSS feed

Aaron Roberts
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand right, there is a single swing dispatch thread which handles all the gui update code. IE pressing a button, makes it show pressed in, calling the registered ActionListeners, etc.

I am unclear on the 'right' way to update a swing component outside the swing thread. The usual one would be a progress bar, but I'm trying to update the graphics image thats painted onto a component. I believe the approach is the same.

Can someone provide some insight here?

Suppose once a second I want to change the color of a button, then I'll need a seperate thread running to do this right? It would have a sleep in it, to avoid sucking all the cpu time.

Is the approach any different if I want to draw a graphic on the component? I know how to use the gfxContext, but don't know if its 'safe' to call paint from the non swing dispatch thread.

What's the 'right' way?

Aaron R>
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!