How to make a form refer to the parent frame using a JDialog

Below code segment shows how to use a JDialog to refer to a parent frame.
MyApp.java

public class MyApp {
   JDialog dialog;
   JFrame parentFrame;

   public static void main(String[] args) {
      MyApp app = new MyApp();
      app.gui();
   }

   public void gui() {
      //The parentFrame
      parentFrame = new JFrame();
      parentFrame = setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      //The dialog
      dialog = new JDialog(parentFrame, "My New Application v 1.0"):
      dialog.addWindowListener(new CloseWindowListener());

      dialog.setSize(300, 300);
      dialog.setResizable(false);
      dialog.setVisible(true);
   }

   //The close window event handler
   public class CloseWindowListener implements WindowListener {
      public void windowClosing(WindowEvent ev) {
         dialog.dispose();              //First, dispose the dialog
         parentFrame.dispose();         //Then, dispose the frame
      }
   }
}