Search code examples
javaswingjframejcomponent

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


We add a parent to a JDialog by invoking super class constructor i.e super(parent).

Now I want to know is there any way using which I can add a parent component after my component is created.

Logic I know:

public MyJDialog(JFrame frame){

super(frame);

}

what I want is

public JDialog(){

super();

}

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

Solution

  • It seems there is no way to set it. The alternative ways are described in below qsn : Is there a way to change the owner of a JDialog?