title: Restart and close program using JDialog
body: <p>I have an application where the user matches cards. And when the user matches all the cards in the game I have a JDialog box that opens with the option for yes or no. But I am not sure how to make it so that when the user selects yes it restarts the application and when the user selects no the application and JDialog box close.</p>
  
  <p>This code is all apart of the MemoryUI java file:</p>
  
  <pre><code>   if (cardsLeft == 0) {
     JFrame parent = new JFrame();
  JOptionPane optionPane = new JOptionPane(" Restart?",JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
  JDialog dialog = optionPane.createDialog(parent, "Manual Creation");
  dialog.setVisible(true);
  
      }
  </code></pre>