Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Application Modal JDialog is blocking its child JDialog

 
Rob MacKay
Ranch Hand
Posts: 35
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.
 
Paul Clapham
Sheriff
Posts: 20711
29
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Rob MacKay
Ranch Hand
Posts: 35
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20492
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic