Java - pausing the program for a moment

dropadrop

Gawd
Joined
Feb 28, 2001
Messages
569
I'm working on a program that needs to load some user information from the harddisk. When the program is opened up it checks to make sure the necassary files are on the disk, and if not found (first time?) it launches a separate class with fields to enter the needed info which saves them to disk.

My problem is, that I need to find a way to stop the main programs excecution untill these values have been saved. Currently the panel requesting settings opens up, but the main program keeps loading. Once loaded it crashes as it does not have the necassary info... :rolleyes:

Code:
...
			File test = new File("c:/tauko/user.cfg");
			boolean secondTime = test.exists();

			if (!secondTime) {
				Settings newOnes = new Settings(); // starts a class to ask for values
			}
...

How to get this to pause?

edit: The program is not using threads.
 
It's very hard to tell from your code, but I assume that Settings is going to spawn some sort of JFrame or JDialog window. In order for the execution to block in that window, you need to make it MODAL. The Javadocs can tell you how to make JFrame/JDialog modal. Your best bet is probably a JDialog since that fits your task. You'll probably have to extend JDialog to get any decent functionality out of it.

Start here

http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html
 
Back
Top