Possible Duplicate:
Java - Leaking this in constructor
In the NetBeans I have a JDialog that contains a JPanel. I am trying to pass a reference of the JDialog to the JPanel. Please take a look at my code below. When I do it the way I did I receive the "Leaking this in constructor" warning. I understand why, but I don't know how to fix this. I also know that I can use @SuppressWarnings("LeakingThisInConstructor") but isn't there a real way to fix this without suppressing the warning?
public class MyJDialog extends javax.swing.JDialog {
public MyJDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
MyJPanel.getThis(this);
}
}
public class MyJPanel extends javax.swing.JPanel {
private JDialog dialog;
public MyJPanel() {
initComponents();
}
public void getThis(JDialog dialog){
this.dialog = dialog;
}
}