aspose file tools*
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JDialog question" Watch "JDialog question" New topic
Author

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.

Thanks,

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
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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.
 
 
subject: JDialog question