Closing/Disposing two forms at once after logging in

37 Views Asked by At

So the Login.java (first form) is like a homepage then a JButton "Start" is in the middle of the Login.java which appears the LoginStudent.java where the user enters their email and password. Therefore both forms are on setVisible(true)

The problem is after logging on in LoginStudent.java, yes the form closed however the Login.java didn't closed. It just displayed behind the dashboard.

I did try the Login a = new Login(); which links to the first form or the Login.java. Here's the code I input:

/**
logging in using ENTER key, same code to jButtonActionPerformed
I'm using JFrame Form
**/

private void passTextKeyPressed(java.awt.event.KeyEvent evt) {

if(evt.getKeyCode() == KeyEvent.VK_ENTER){ 

Login a = new Login();

if (rs.getString("type").equals("STUDENT")) {
        studentDashboard std = new studentDashboard();
        std.setVisible(true); //this appears the dashboard after logging in
        this.dispose();
        a.dispose(); //also tried the a.setVisible(false); 
                        
                    } 
     }
}

I'm still a second year student college studying under Information Technology and I don't know a lot yet. I'm working on a system database out of hobby.

0

There are 0 best solutions below