• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating a non-modal JDialog

 
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to write a non-modal JDialog and getting this exception:

java.lang.IllegalArgumentException: adding a window to a container

However, the JDialog seems to display just fine (I have not yet added any UI fields to it yet). This JDialog is launched from my JFrame menu class:

The exception is on line 55 of the JDialog class:

I assume this has something to do with the way I am providing the JFrame object. Can someone help me out with this? TIA.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want that frame to be the owner of the JDialog then what you would do is this:



I don't recall ever seeing code which adds a dialog to a frame, and it doesn't make sense to do that because the dialog isn't part of the frame. So I would just leave line 55 out.
 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply. That is actually where I started out but the dialog would not display. After I added that then I got it to display but with that exception. Apparently in the mean time I must have unknowingly fixed something else that was the real cause of it not displaying. After removing that as you suggested, it still displays but with out the exception.
 
reply
    Bookmark Topic Watch Topic
  • New Topic