除了 super(parent) 之外,还有什么方法可以将 Parent 添加到 JComponent

Is there any way to add a Parent to a JComponent apart from super(parent)

我们通过调用超级 class 构造函数将 parent 添加到 JDialog 即 超级(parent).

现在我想知道有什么方法可以在我的组件创建后添加一个 parent 组件。

我知道的逻辑:

public MyJDialog(JFrame frame){

super(frame);

}

我想要的是

public JDialog(){

super();

}

void setParent(JFrame frame)
    {
    this.setParent(frame);//just an example, I am looking for an actual API
}

对于JDialog,您只能在使用构造函数时设置所有者。
如果您将 null 作为所有者传递给构造函数 - 那么将为您分配一个。
之后,您无法更改或重新设置所有者。

好像没办法设置。 替代方法在下面的 qsn 中描述: Is there a way to change the owner of a JDialog?