I'm trying to achieve the following: Show login window, then  from factory to determine what GUIclass to open for instance (admin/dev/tester).  
I cannot manage to make the second window pop up; I tried with dispose it closes the program but not runs the main to the end.
main:
public static void main(String[] args){
        LoginGui loginGuiWindow = null;
        DeveloperGui devGui = null;
        TesterGui tesGui = null;
        UserCntrl uc = new UserCntrl();
        try {
            loginGuiWindow = new LoginGui(uc);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.print("Checking instance of: ");
        if(loginGuiWindow.loggingResult > 0){
            System.out.print("Checking instance of: ");
            if (uc.user instanceof Developer) {
                System.out.println("is instanceOf developer");
                devGui = new DeveloperGui(uc);
            }
            if (uc.user instanceof Tester ) {
                System.out.println("is instanceOf tester");
                tesGui = new TesterGui(uc);
            }
        }
    }
LoginGui:
btnNewButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                int res;
                String nick = textUser.getText();
                String pass = textPassword.getText();
                if((res = uc.handleLogin(nick, pass)) > 0){
                    loggingResult = res;
                    uc.handleUi(res);
                    frame.setVisible(false);
                    frame.dispose();
                }
                else{
                    JOptionPane.showMessageDialog(frame,
                        "Wrong username or password.",
                        "Logging error",
                        JOptionPane.PLAIN_MESSAGE);
                }
            }
        });
 
     
     
    