public Window openWindow(Integer type){
        if (windows.containsKey(type)){
            final Window existing = windows.get(type);
            System.out.println("Opening existing");
            //Move the window to front
            java.awt.EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    existing.toFront();
                    existing.repaint();
                    existing.setVisible(true);
                }
            });
            
            return existing ;
        } else {
            Window window = null ;
            
            if (type == Window.LOGIN){
                window = new LoginWindow(app);
                window.setResizable(false);
                window.setTitle("MemoryPro [login]");
                window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            } else if (type == Window.REGISTER){
                window = new RegistrationWindow(app);
                window.setResizable(false);
                window.setTitle("MemoryPro [registration]");
                window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            } else if (type == Window.MAIN){
                window = new MainWindow(app);
                window.setTitle("Welcome to MemoryPro");
                window.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
                
            } else if (type == Window.NEW_NOTE){
                window = new NewNoteWindow(app);
                window.setTitle("MemoryPro [new note]");
                window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            } else if (type == Window.ACCOUNT){
                window = new AccountWindow(app);
                window.setTitle("MemoryPro");
                window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            }
            
            if (window != null)
                this.setupNewWindow(window, type);
                
            return window ;
        }
    }