This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JDialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JDialog "owner"" Watch "JDialog "owner"" New topic
Author

JDialog "owner"

Stephanie Grasson
Ranch Hand

Joined: Jun 14, 2000
Posts: 347
Hi all!
Most of the JDialog constructors take an "owner" as the first argument ( either a Frame or a Dialog ). Does anyone know what the JDialog class uses this for?
I have noticed that I can call these constructors passing null for the first argument and I still get a JDialog with no immediately apparent problems. However, this seems strange to me. If it's in the argument list, there must be a need for it somewhere down the line.
Any insight would be greatly appreciated.
Thanks!
Stephanie
Angela Lamb
Ranch Hand

Joined: Feb 22, 2001
Posts: 156
Dialogs are attached to their parent frames. For example, if you minimize the parent frame, the dialog will also disappear.
Passing a null value as the parent doesn't cause any major errors. However, it can cause some unintended behavior in the dialog, such as the dialog staying visible even though all the other frames in the parent application have been closed.
[This message has been edited by Angela Ann (edited March 15, 2001).]
Stephanie Grasson
Ranch Hand

Joined: Jun 14, 2000
Posts: 347
Angela,
Thank you very much for your answer!
I was curious about one other thing:
Most of the JDialog constructors have mirror versions whether the owner is a Frame or a Dialog, for example:
JDialog(Dialog owner);
JDialog(Frame owner);
If you send null, how does Java resolve this ambiguity?
Thanks for your input.
Stephanie
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Angela:
Dialogs...
Passing a null value as the parent doesn't cause any major errors.
you mean JDialogs!
java.awt.Dialog)" TARGET=_blank rel="nofollow">Dialogs according to the API throw IllegalArgumentException when owner is null.
I spent sometime reading the API for answering this post,
and since I couldn't find anything I gaveup. Just din't
want my hardwork to go waste, so I am picking on your stmt!
Hope you don't mind the minor correction.
regds.
- satya

[This message has been edited by Madhav Lakkapragada (edited March 15, 2001).]


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Angela Lamb
Ranch Hand

Joined: Feb 22, 2001
Posts: 156
You have to explicitly cast to either a Frame or a Dialog when using a null as the owner parameter, otherwise a compile-time error will occur.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDialog "owner"
 
Similar Threads
modeless JDialog?
Casting a null object...
question in javaquiz
modeless dialogs in swing
Annoying quirk with JDialog on Windows 7