Note that there are some explanatory texts on larger screens.

plurals
  1. POForm freezing issues after accessing dialogue box
    primarykey
    data
    text
    <p>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.</p> <p>Here is my code from the event handler method:</p> <pre><code>//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(); } } } } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload