I am writing a program that will open another form, the user will continue doing stuff on the new form and would then close the form. When and only when this new form closes, the main form should continue with its work and re-enable some components. Here is the code:

// If the user account exists then load the transaction form
        if(userAccountExists == true) {
            // Create a new instance of the ATMTransactionOptions form
            ATMAccountData atmAccountData = accounts.get(0);
            ATMTransactionOptions ato = new ATMTransactionOptions();

            // Pass the account data to the new form
            ato.setATMAccountData(atmAccountData);

            // Clear the current account data in the atmAccountData 
            atmAccountData.clearAll();

            // Clear the current form data
            edtAccountNumber.setText("");
            pwdPassword.setText("");

            // Disable the form input methods
            edtAccountNumber.setEnabled(false);
            pwdPassword.setEnabled(false);
            btnLogin.setEnabled(false);

            // Display the form
            ato.setVisible(true);

            // The program should wait here until the ATMTransactionOptions (ato) form is closed
            // only then should it continue to the following lines
            /*edtAccountNumber.setEnabled(true);
            pwdPassword.setEnabled(true);
            btnLogin.setEnabled(true);*/
        }

Currently its commented out, else the program re-enables the components.

Just have a method that re-enables the components, and call that as part of whever listener is handling the close of the other window.

This question has already been answered. Start a new discussion instead.