Meaningless Drivel is fun!
The moose likes Swing / AWT / SWT and the fly likes Application Modal JDialog is blocking its child JDialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Application Modal JDialog is blocking its child JDialog" Watch "Application Modal JDialog is blocking its child JDialog" New topic

Application Modal JDialog is blocking its child JDialog

Rob MacKay
Ranch Hand

Joined: Apr 06, 2007
Posts: 35
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?

Thanks in advance.
Darryl Burke

Joined: May 03, 2008
Posts: 5115

To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.

luck, db
There are no new questions, but there may be new answers.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

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.
Greg Brannon

Joined: Oct 24, 2010
Posts: 563
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?

Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Rob MacKay
Ranch Hand

Joined: Apr 06, 2007
Posts: 35
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.
Rob Spoor

Joined: Oct 27, 2005
Posts: 20271

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

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Application Modal JDialog is blocking its child JDialog
It's not a secret anymore!