title: Java Swing - .dispose() method not closing JFrame
body: <p>I'm writing a simple game that is based on two JFrames. The user is only displayed on JFrame at a time. To get to the other JFrame, the user clicks a button. The button in the new JFrame will have an overriden method that should navigate the user back to the old JFrame. </p>
  
  <p>I've found success doing this however the .dispose() method doesn't seem to close the new frame when the user tries to navigate back to the old frame. </p>
  
  <p>Here's a snippet of my code (original JFrame class):</p>
  
  <pre><code>public class TicTacToe extends JFrame implements ActionListener{
  
  ....
  
  public class gameModeListener implements ActionListener
  {
      @Override public void actionPerformed(ActionEvent e)
      {
          TicTacToeSingle singlePlayer = new TicTacToeSingle();
          singlePlayer.setVisible(true);
          dispose();
      }
  }
  }
  </code></pre>
  
  <p>And from the other JFrame class:</p>
  
  <pre><code>public class TicTacToeSingle extends TicTacToe{
  
  private int i;
  private int j;
   JButton boardArray[][];
   Random random_generator = new Random();
   int randomI;
   int randomJ;
  
  public TicTacToeSingle()
  {
      super("Single Player");
      gameMode.setText("Two Player"); //gameMode is the button that has it's actionlistener method overriden. It navigates the user to and back from JFrame to JFrame
  
      gameMode.addActionListener(new gameModeListener()); 
  
      ....
  }
  
   ....
  
  public class gameModeListener implements ActionListener
  {
      @Override public void actionPerformed(ActionEvent e)
      {
          TicTacToe twoPlayer = new TicTacToe("Two Player");
          twoPlayer.setVisible(true);
          dispose();
      }
  }
  </code></pre>
  
  <p>Your help is greatly appreciated :)</p>