JoptionPane Validation
===

Hi guys I have a Swing GUI where I am restricting the User Registration so that the username and the Password cannot be the same. I Am using JoptionPane for the Task using the following Code:

    public void actionPerformed(ActionEvent e) {
                String username = tuser.getText();
                String password1 = pass1.getText();
                String password2 = pass2.getText();
                String workclass = wclass.getText();
                Connection conn = null;

                try {
                    if(username.equalsIgnoreCase(password1)){
                       JOptionPane.showMessageDialog(null, "Username and Password Cannot be the same. Click OK to Continue", "Error",
                                JOptionPane.ERROR_MESSAGE); 
                       System.exit(0);
                    }

Problem is I had to use:

    System.exit(0);
because Without it the next code was getting executed and So even after the Joptionpane pops up, the registration was getting Successful. I do not need the System to exit But I need the user to be kept on the Registration Page after the Validation. What Is the best way to do this?? Is there other convenient ways of doing this rather than using the JoptionPane??