File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Prompting User modally without a Frame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Prompting User modally without a Frame" Watch "Prompting User modally without a Frame" New topic
Author

Prompting User modally without a Frame

Thom Pischke
Greenhorn

Joined: Aug 22, 2003
Posts: 3
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
Thom Pischke
Greenhorn

Joined: Aug 22, 2003
Posts: 3
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:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Prompting User modally without a Frame