Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDialog "owner"

 
Stephanie Grasson
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 347
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Angela Lamb
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic