• Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread repaint issues

 
Cathy Song
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a GUI interface which performs some computation when a button is pressed. Since this compuation takes a while, I put this compuation code in a another thread, such that the GUI is not frozen. Now the problem is that the GUI is not being repainted when the spawned thread stops. How can I poll the spawned thread to check if it is alive or not, and if it is not alive, I want to repaint the GUI. If there are other solutions please let me know.

Thanks a bunch,

Cathy.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Directly or indirectly, have the other thread call repaint() on the appropriate Component before it exits. You could pass the component to the Thread class as a constructor argument.
 
Cathy Song
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that solved my problem
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using SwingUtils.invokeLater? I think the worker thread that computes the answer should use that mechanism to return the results to the Swing thread. I had an app that would only repaint when I resized the window until I found this.
 
Cathy Song
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Stan,

Actually I did try the invokeLater() but that did not
work for me.

Thanks,
Cathy.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm, I wonder why. Can any other experts explain?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!