I've looked around and can't find any answer to this question.
I have an application with a series of JDialog objects. These are created and managed individually and one of them, on the click of a button, needs to open up a child JDialog which in turn asks the user for some data, etc.
The parent is Application Modal and so is it's child JDialog that I am creating when the button is pressed.
The problem is that the child dialog pops up but is being blocked by it's parent and not accepting any focus or commands. Killing the parent also kills the child.
I am looking for behaviour similar to a call to the JFileChooser class which pops up the file chooser dialog and that dialog actually blocks the parent that spawned it until you close it.
Any ideas on how to get my modal parent to play nice with it's modal child?
I don't have an answer for you, except that I find user interfaces which cascade through a bunch of dialog boxes to be rather irritating. It seems that I'm not alone in this because typically you see the "wizard" style of interface where all of the steps appear in the same box. Perhaps you might consider this: it would at least make your existing problem go away.
I agree that a code example of the problem would be helpful.
You say the child JDialog is also modal and I assume that user input of some kind is expected. Does the child JDialog and/or its components have the necessary ActionListeners attached and actionPerformed() method defined?
Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
Joined: Apr 06, 2007
Yes, the child dialog does contain all of the listeners, it just won't accept focus from the parent.
I do agree with the other poster that cascading dialogs are somewhat annoying so I will probably try to contain everything in a single panel. Certainly it'll be a little easier then trying to manage popups that require user input like this.
Strange though that a simple call to a JFileChooser works as expected.
Are you sure the dialog has the right parent window? An SSCCE would still help. In this case, all the SSCCE would need is:
- a main JFrame - with a button
- that creates a first modal dialog when clicked
- which contains a button
- that creates the second modal dialog when clicked