Forums Register Login

JDialog question

+Pie Number of slices to send: Send
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 );
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Yes, that works.
Thanks alot.
I love a good mentalist. And so does this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1007 times.
Similar Threads
problem with closing JDialog created with JFrame
closing JDialog when focus is lost
Problem with JDialog
JDialog Question
JDialog question
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:03:03.