vaddin subwindow alignment with browser size

Hi we are using popup window for search that display at center of browser by using center(),and it is fixed size and width not re-sizable ,But problem is when we maximize and minimize the browser it will not change position according to browser size ,so How to make a popup re-size-able according to browser ,i want at center always and it has to change position when browser is maximize and minimize

Hi,

You can add a Window.ResizeListener to your mainWindow.


public class TestApplication extends Application {
            
    private static final long serialVersionUID = 1L;

    @Override
    public void init() {
        Window mainWindow = new Window("MyApplication");
        setMainWindow(mainWindow);
        mainWindow.setImmediate(true);
        
        final Window w = new Window("subWindow");
        w.setImmediate(true);
        
        mainWindow.addListener(new Window.ResizeListener() {
			
			public void windowResized(ResizeEvent e) {
				w.center();
				
			}
		});
        
        mainWindow.addWindow(w);
        w.center();
      
    }
}

Hope it’s works.

Regards.

Éric