position window on top right corner of screen

Hi All

I’m new to Vaadin, so far I find it fantastic. What got me with GWT was A)the slow compiler and B )The network gap, client and server being separate is far from transparent.

Anyway, I’ve been lashing into an app with Vaadin but I’ve come across a bit of an issue which I haven’t yet solved so I’m hoping you can help, thanks.

How can I position a subwindow in the top right corner of the screen when the app loads. The problem is that I cannot get the size of the main window, the getHeight() and getWidth() both return -1 therefore I cannot calculate to position the window in the top right corner.

Any ideas or help much appreciated.

Thanks Very Much
John

Here is a way to keep window in top-right corner of the main window.

Unfortunately, I encountered some regression problems with Window resize handling which makes it require manual resize at first. This should be fixed in 6.4 trunk.

        final Window mainWindow = new Window("Main Window");
        mainWindow.addListener(new Window.ResizeListener() {

            private static final long serialVersionUID = 1L;
            private Window w;

            private void showOnTopRight(Window mainWindow) {
                if (w == null) {
                    w = new Window("Subwin");
                    w.setWidth("200px");
                    w.setHeight("100px");
                    w.addComponent(new Label("I'm here!"));
                    mainWindow.addWindow(w);
                }
                int margin = 20;
                w
                        .setPositionX((int) (mainWindow.getWidth()
                                - w.getWidth() - margin));
                w.setPositionY((margin));
            }

            public void windowResized(ResizeEvent e) {
                showOnTopRight(mainWindow);
            }

        });
        mainWindow.setImmediate(true);
        setMainWindow(mainWindow);