wood burning stoves
The moose likes Swing / AWT / SWT and the fly likes JDialog question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JDialog question" Watch "JDialog question" New topic

JDialog question

Duane Riech
Ranch Hand

Joined: Feb 27, 2003
Posts: 52
I know this is very basic question but I can't get a clear example.
I have created a class that extends JDialog.
I want to create an instance of it from within a JPanel which has as it's
ultimate parent a JFrame.
How do I get the "owner" or first parameter for the super() call? I tried
getContentPane() but then I get a compiler error.
I'm not finding enough documentation in my reference books to understand
what it needs.


public class IngrIdentDialog extends JDialog {
public IngrIdentDialog( Dialog parent, String title,
boolean modal, Vector data ) {
super( parent, title, modal );
} /* ...end of public constructor IngrIdentDialog... */
} /* ...end of class declaration IngrIdentDialog... */

IngrIdentDialog dialog = new IngrIdentDialog( getContentPane(),
"a title",
true );
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Any component can call getParent() to get the Container it's inside of. If you call getParent() in a loop, you'll always walk up to a JFrame, Frame, JDialog, Dialog, or something of this nature.

[Jess in Action][AskingGoodQuestions]
Duane Riech
Ranch Hand

Joined: Feb 27, 2003
Posts: 52
Yes, that works.
Thanks alot.
I agree. Here's the link: http://aspose.com/file-tools
subject: JDialog question
It's not a secret anymore!