Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Forcing Swing components to block  RSS feed

 
Richard Robbins
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing an application that calls a function which brings up a JFrame window. I want the calling thread to block until user input has been entered into the JFrame window. How do I accomplish this?
 
SAFROLE YUTANI
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of using a JFrame, see if it's possible to accomplish getting the text from the user by displaying a JDialog instead. If so, you can block the caller while the JDialog is showing by having previously called JDialog.setModal(true) before the JDialog displays. This should effectively block the caller until the JDialog is disposed.
If this does'nt work, then from the caller's code, create a synchronized block that waits on the JFrame that is displayed. After the text is entered, notify the caller using notify() to continue processing.
SAF
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!