Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDialog question

 
Duane Riech
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Duane Riech
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that works.
Thanks alot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic