JDialog mode and class extension


So, I need to create a class that extends JDialog, to remove JDialog code from the main functions code.

However, I don't know how to set it's parent JFrame after the JDialog has been created.

It's usually done by passing the JFrame to the constructor, but since it's a custom class, I don't know how to set it to be JDialogs parent. I couldn't find any method of type JDialog.setParent(JFrame); I hope you understand the problem.

Any suggestions?

The parent Window (Frame or Dialog) is called owner in the APIs. You can only mention it in the constructor by calling the super class (JDialog) constructor.


public class SomeDialog extends JDialog {

  public SomeDialog() {
    // see other JDialog constructors for other ways to call this
    super(parentWindow, title, ModalityType.DOCUMENT_MODAL);


You cannot set it later, after your custom JDialog has been created.