I took on the advice to use a JFrame for my first screen, and a JDialog for al the other screens. I use a strategy pattern to separate the looks from the behaviour. In the constructor of my behaviour class I instatiate the class for the looks:
Where TafelView is my new screen (JDialog)
Unfortunately, these lines won't run, because it stops on the line that makes the JDialog:
I believe Dialogs are intended to prompt user input:
A Dialog window is an independent subwindow meant to carry temporary notice apart from the main Swing Application Window.
The Swing Tutorial: How to make Dialogs.
so they pause the execution of the thread they are spawned from.
If you don't want to wait for user input, I believe you'll want to use another Frame (or InternalFrame, if you want to block input to the main frame).
Well, I have a main frame, with a couple of buttons on it. When one of those buttons is clicked, a second window comes up. That second window has a form on it; a couple of labels + textfields, and two buttons "save" and "cancel". I first did it with a JFrame, but was advised to use a JDialog instead. But then this problem arises, and I don't know what to do know.
Besjamain Greenaway wrote: I first did it with a JFrame, but was advised to use a JDialog instead.
I looked through your previous posts for that advice and couldn't find it. Why was a JDialog advised over a JFrame?
Joined: Dec 21, 2007
Well, here is part of one it:
Wouldn't you be better off having a JDialog sitting above the main JFrame rather than a second JFrame? Then there is absolutely no danger of closing the app when the dialog closes, you can better control modality type, and you can guarantee that the subwindow always sits above the main one.
I read about it somewhere else as well, but I can't find it that quick, although I have a hunch that I read it on Sun's website somewhere. But I'm guessing that you say that it's okay?
Google says it is here. I just wanted to see the context of your question and the answer.
I would not say using JDialog is "OK". It doesn't do what you want it to do. I think you have two options (there may be more):
1. use a JDialog with the understanding that processing in that thread halts
2. use a second JFrame or a JInternalFrame and continue processing in the background.
Joined: Dec 21, 2007
Well, I guess I'm back to using JFrame again Thank you for answering my question.