This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, I'm finishing up my project and working on some configuration details. Based on posts here and my own biases, I've decided on the following scheme for configuration: A Server GUI ControlPanel will operate in networked-mode and will prompt for port and db file location and offer start and stop buttons. The Client GUI will be responsible for maintaining the machine/url/ip address information needed to establish an RMI connection in networked mode. In Standalone, neither of the above will be needed, and instead a simple dialog will pop up, prompting for a database location. This will be one simple window. Now my question. When I display this window, it runs in a new thread. The original thread keeps chugging, although it is dependent on user input from the input window. How can I suspend the main thread elegantly until the user has performed the input and closed the dialog? I've tried using a modal JDialog, but that only works when the other threads are GUI threads, not when instantiating from main() for instance with no parent frame. I'd like something that roughly models the following scheme: DBDialog extends JDialog and just contains instructions to build itself and a getDBFile() method to retrieve whatever the user entered.
The problem is that the second line executes before the Dialog has been dismissed, even though the Dialog is modal. Is there a way to make this work, or am I going about this user input completely the wrong way? HELP! Thom
Never express yourself more clearly than you think. - Niels Bohr
Joined: Aug 22, 2003
Okay, I lied. The code sample in the original post actually does work as desired (provided of course one uses a real constructor). My code now appears as follows, and seems to do the job well: