Problem z ActionListener i ponownym załadowaniem gui

0

Witam, tak jak w temacie, po wpisaniu nieprawidłowych danych logowania program się zawiesza. Nie za bardzo potrafię dojść do ładu z tym.

if (actionSource == loginButton) {
            try {
                String stringInput = idField.getText();
                tempid = stringInput == null || stringInput.isEmpty() ? 0 : Integer.parseInt(stringInput);
                tempSurname = surnameField.getText();
                tempPassword = passwordField.getText();
                if (loginPanel(userData, userLogin)) {
                    removeGui(loginUiList);
                    mainUi();
                } else {
                    infoText.setText("Błędne dane");
                    infoText.repaint();
                    removeGui(loginUiList);
                    loginUi();
 static boolean loginPanel(User userData, User userLogin) throws IOException {
        userLogin.login();
        userLogin.read(userData);


        if(userLogin.check(userData, userLogin)){

            return true;
        } else
            return false;

    }

Tu metoda sprawdzająca

 public boolean check(User userData, User userLogin) {
        System.out.println("User ID: "+getUserId()+ " Data ID: "+userData.getUserId());
        System.out.println("Z pliku: "+userData.getUserSurname()+", "+userData.getUserPassword());
        System.out.println("Od uzyt: "+userLogin.getUserSurname()+", "+userLogin.getUserPassword());
        System.out.print("Sprawdzanie danych ID, Nazwisko, Haslo:   ");

        if (getUserId()==userData.getUserId()) {
            System.out.println("ID - OK");
        } else{
            System.out.println("Bledny numer ID uzytkownika.");
            return false;
        }

        if(userLogin.equals(userData)) {
            System.out.println("Dane prawidlowe");
        } else{
            System.out.println("Bledne nazwisko lub haslo!");
            return false;
        }
        return true;
    }
0

Musisz podać cały kod.nie wiadomo co to jest loginUi i removeGui. A tam pewnie jest problem. I nie wiadomo po co tam jest repaint.

0

Do zamknięcia problem rozwiązany. Zmieniłem kolejność w else

if (actionSource == loginButton) {
            try {
                String stringInput = idField.getText();
                tempid = stringInput == null || stringInput.isEmpty() ? 0 : Integer.parseInt(stringInput);
                tempSurname = surnameField.getText();
                tempPassword = passwordField.getText();
                if (loginPanel(userData, userLogin)) {
                    removeGui(loginUiList);
                    mainUi();
                } else {
                    removeGui(loginUiList);
                    loginUi();
                    infoText.setText("Błędne dane");
                    

1 użytkowników online, w tym zalogowanych: 0, gości: 1