Center a LoginForm

Can’t get a LoginForm component to center in a Window. The code is:

            loginForm = new LoginForm();
            loginForm.addListener(this);
            loginWindow = new Window("Login");
            loginWindow.addComponent(loginForm);
            ((VerticalLayout) loginWindow.getContent()).setComponentAlignment(loginForm,
                    Alignment.MIDDLE_CENTER);
            loginWindow.setResizable(false);
            loginWindow.setWidth("200px");
            loginWindow.setHeight("250px");
            loginWindow.center();
            setMainWindow(mainWindow);
            mainWindow.addWindow(loginWindow);

The functionality works fine, it just won’t center. Am I doing something wrong?

Yes! I just finished converting my login form and get the exact same behaviour. My original form was a modal window, but I read about the security issue somewhere on the site and decided that I’ll probably just using the form. I’m still using a Window (just nor modal), just as you are doing.

See e.g.
this thread
.