• Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread effect on GUI and how to handle

 
Danny Krinkle
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I feel this is more related to threads than the GUI itself.

As an experiment into multithreading I have been working on an application that checks to see if a number of computers are reachable and then displays the results in a table.

I have this working but there is one thing that is bugging me. When the 'check hosts' button is clicked, the hosts are checked and the table is updated fine but during this time the gui is unusable and the button is in a 'pressed' state. If I remove the line t.join();, I get the desired behavior from the GUI but the table is not refreshed (which I would expect)

Im not after a soultion, just a pointer or examples to help me with the next step to resolve this. I would basically like to click the button and have the tabel refresh after all the threads have done their bit, but without the button remaining 'pressed'.

Kind Regards

Dan

 
Chris Hurst
Ranch Hand
Posts: 443
3
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check out swing worker. It'll do exactly what you want, giving you a re-entry point after the job that you post off the EDT (Event Dispatch Thread) to update the table model. Be careful not to mutate the table model off the EDT.
 
Danny Krinkle
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris,

You're my saviour. The last thing I need before the weekend is a niggle about this button!!

Cheers

Dan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!