I'm in the process of creating a login mechanism for a game. If the user inputs an invalid username-password combination, a dialogue box appears telling them their error. But when I click "OK" in the dialogue box, all components in the previous form become inactive.
Here is my code from the event handler method:
//Event Handler
public void actionPerformed(ActionEvent e){
    Scanner fileScan = null;
    Scanner passwordScan = null;
    String lineVar; 
    int lineCount=0;
    //Opens the "Create Account" form
    if (e.getSource()==CreateNew){      
        new CreateAccount();        
    }
    //user tries to login 
    else if(e.getSource()==submit){
        Inputuser = user.getText();
        InputPass = Pass.getText();
        try{
            fileScan = new Scanner(new File(Inputuser + ".txt"));
            filefound = true;
        }
        catch(FileNotFoundException ex){
            JFrame FailureFrame = new JFrame("Something went wrong...");
            JOptionPane.showMessageDialog(FailureFrame, "The username you have entered does not exist in our records. Please try again");
            filefound=false;
        }
        //If the file was found (username exists)
        if (filefound==true){
            //Loops while the username while has more lines of content          
            while(fileScan.hasNext()){
                lineVar = fileScan.next();
                //Each line is considered a token
                passwordScan = new Scanner(lineVar);
                passwordScan.useDelimiter("/n");
                while (passwordScan.hasNext()){
                    lineCount +=1;
                    if (lineCount == 2){
                        if (InputPass.equals( passwordScan.next() ) ){
                                JFrame successframe = new JFrame("Success!");
                                JOptionPane.showMessageDialog(successframe, "Login Successful!");
                                frame.dispose();
                                new MainProfile();
                        }
                        //If the password they entered is wrong     
                        else{
                            JFrame notLogin = new JFrame ("Something went wrong...");           
                            JOptionPane.showMessageDialog(notLogin, "You have entered invalid info. Please try again"); 
                            CompEnable();   
                        }
                    }
                }
            }
        }
    }
}
 
     
    