title: How to properly hide a JFrame
body: <p>I have a very simple <code>JFrame</code> window that contains one button: <code>No</code>.</p>
  
  <p>In the main function I set <code>setVisible(true);</code> my <code>JFrame</code> and in the <code>No</code> button listener I want to close the window so I set the visibility to false: <code>setVisible(false);</code> and after that I do <code>System.exit(0);</code> in order to prevent possible memory leaks when running the program many times. </p>
  
  <p>I have two questions:</p>
  
  <ol>
  <li>Do I really need to <code>System.exit(0);</code> in the above case?</li>
  <li>If I have this <code>JFrame</code> as a <code>popup</code> window, I can't really use <code>System.exit(0);</code> because this will terminate the whole program. So how can I properly close the popup window and stay in the main <code>JFrame</code> window? (Now I close it only by <code>setVisible(false);</code> and when I do it several times through the program execution, the program turns very slow).</li>
  </ol>