I am making a small Java project in which there are 3 frames connected together, say f1, f2, f3 & f4. f1 is having a button and after clicking it it calls f2 and f2 also has button which calls f3. The problem is if I opened all the form one by one then when I close form f2 or f3 then the main form(f1) gets closed. 
I want that even I close form f2 and f3 my main form should not be close until I close it personally. 
package mnm;
public class NewJFrame extends javax.swing.JFrame {
    public NewJFrame() {
        initComponents();
    }
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        NewJFrame1 nb=new NewJFrame1();
        nb.setVisible(true);
    }
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewJFrame().setVisible(true);
                NewJFrame gn=new NewJFrame();
                gn.setDefaultCloseOperation(NewJFrame.DISPOSE_ON_CLOSE);
            }
        });
    }
    private javax.swing.JButton jButton1;
}
 
    
 
    