title: Opening two new JFrames! Why is this happening?
body: <p>This code checks the username and password then opens a new JFrame if they are correct. However, two identical JFrames are opened and I am clueless as to the reason.   </p>
  
  <pre><code>public void checkLogin(String x, String y){
          if (x.equals(loginCredentials[0]) &amp;&amp; y.equals(loginCredentials[1])){
              dispose();
              task1ExampleSC o2 = new task1ExampleSC();
              o2.setVisible(true);
              o2.setSize(600,650);
              o2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          }else{
              System.exit(0);
          }
      }
      private class loginAC implements ActionListener{
          public void actionPerformed(ActionEvent e){
              String usernameText,passwordText;
              if (e.getSource()==login){
                  usernameText = username.getText();
                  passwordText = password.getText();
                  checkLogin(usernameText,passwordText);
              }else if(e.getSource()==cancel){
                  System.exit(0);
              }
          }
      }
  </code></pre>