Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Application Modal JDialog is blocking its child JDialog

 
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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • 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.
 
Sheriff
Posts: 24594
55
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.
 
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.
 
Sheriff
Posts: 21775
103
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!