title: Opening a new JFrame and close previous after clicking button
body: <p>How can I code a button that, when clicked, closes the current <code>JFrame</code> and opens a new one?</p>
  
  <p>This is what I have so far, but the old frame stays open:</p>
  
  <pre><code>private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
      practise1 s = new practise1();
      s.setVisible(true);
  } 
  </code></pre>
  
  <p>I have tried using <code>.close()</code> after the first <code>{</code> but it gives me an error.</p>