title: Java - Switch Jframes if JBDC makes a successful connection
body: <p>I have not found a way to return if a connection attempt was successful or not.  I want a user to log on one Jframe and, if successful, switch to another Jframe.  I provided the code I have so far. Any information to help with this welcomed.  Thanks in advance.</p>
  
  <pre><code>private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
      try {
          // TODO add your handling code here:
          ConnectDatabase connect = new ConnectDatabase();
          String output = new String(passwordField.getPassword());
          connect.getDBConnection(usernameField.getText(),output);
          //this.dispose();
          //Main main = new Main();
          //main.setVisible(true);
      } catch (Exception ex) {
          Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
          errorLabel.setText("Incorrect username/password");
      }
  }  
  </code></pre>