I am trying to make an else if on a JSwing so the Admin that signs into the login page, can be redirected to the server Jpanel form. The else if isn't working, does anyone have any ideas on how to fix it?
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
String username = userText.getText();
String password = passwordText.getText();
Component frame = null;
if(username.equals("Admin1") && password.equals("password1") //setting the usernames and passwords
|| username.equals("Loz") && password.equals("password1")
|| username.equals("Charlie") && password.equals("password2")) {
JOptionPane.showMessageDialog(frame, "You are successfully logged in!");
setVisible(false); //you can't see me!
dispose(); //Destroy the JFrame object
chatClient second = new chatClient();
second.setVisible(true); //displays the client page
else if (username.equals("Admin") && password.equals("password")
{
JOptionPane.showMessageDialog(frame, "You are successfully logged in!");
setVisible(false); //you can't see me!
dispose(); //Destroy the JFrame object
chatServer third = new chatServer();
third.setVisible(true); //displays the server page
}
}
else {
success.setText("Invalid username or password entered");
}
Aucun commentaire:
Enregistrer un commentaire