• Post Reply Bookmark Topic Watch Topic
  • New Topic

strange thread probs  RSS feed

 
Vikas Kumar Sahu
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
One thread is running in my swing program and that thread eventually return
the vector in my swing programm but due to threading my swing program and thread runs
prallaly, is there any solution to wait my swing prog until the thread ends.
Thanks in advance.
Vikas
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm guess that what you're saying is that you're starting a thread from a button or menu item to perform some long-running calculation, and you want tge GUI to block until the calculation is completed. The way to do this is to set the cursor to the WAIT_CURSOR, make the main JFrame's glass panel visible, and give it an event handler that swallows all events. Then when the thread finishes, it should invoke a callback that undoes all of this.
Here is some of the necesary code.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!