This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript 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!