Hey,
I need to show a 'level select' window in my game, and it's only purpose is to select a level from a list of available levels, and return the filename of that level.
In .NET, I would have made a dialog form, display it with ShowDialog such that the calling code would halt until the form returned, and then used a property to communicate which level was selected. For example, in C# this could look like
csharp Code:
string levelPath = String.Empty; frmLevelSelect f = new frmLevelSelect(); if (f.ShowDialog() == DialogResult.OK) { levelPath = f.SelectedLevel; } if (levelPath != String.Empty) { // ... load level }
The ShowDialog call waits until the DialogResult has been set in the frmLevelSelect form, so we can be sure that, if the user pressed OK, he has actually selected a level.
If I try the same in java, replacing ShowDialog with setVisible(true), then it does not block, but it returns immediately, and obviously the user has had no chance to select a level yet.
How can I do this? Or is there no built-in mechanism for this and should I use threads?




Reply With Quote