title: Log in page which reads details from XML file java
body: <p>I have created a basic log in page in Java that allows a user to log in successfully, however I have hard coded the username and password into the program. I would like to extend the program so it can accept multiple users from the XML File, as hard coding the details will be inefficient. This is the chunk of code that validates the log in details.</p>
  
  <pre><code>private void loginActionPerformed(java.awt.event.ActionEvent evt) {                                      
  
      if(username.getText().length()==0||password.getText().length()==0){
          JOptionPane.showMessageDialog(null,"Mistake");
  
  
      } else if (username.getText().trim().equals("admin")&amp;&amp; password.getText().equals("hello")){
          JOptionPane.showMessageDialog(null, "Success)); 
  
      }else {
  
  
          JOptionPane.showMessageDialog(null, "Error");
      }           
  }
  </code></pre>
  
  <p>This code only allows admin to log in as it is hard coded into the program.</p>
  
  <p>Would the best solution to be to create a new class that reads the XML file and then create a object in the code above with the parameters username and password.</p>