Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
center window only horizontally
Hi All
I have this window which I used to center like
public class View extends Window {
...
public View() {
setModal(true);
setWidth("50%");
center();
...
}
...
}
Works great. However, now I would like to set the Y (vertical) position of this window, and keep it centered horizontally. If I add, for example,
this.setPositionY(10);
the horizontal position is lost.
Any suggestions how to do this ?
cheers
I guess there center-mode is somehow handled differently in Window, but for me this sound like a bug. Setting Y position should not affect the X position at all.
If you cannot find a solution I suggest to file a bug at dev.vaadin.com
had the same issue with a difference in that the width of my sub windows was fixed (to 700px)
Thanks to Henri kerola here is how it was solved:
In window there is a getBrowserWindowWidth() which helps in this situation since then you can do something like :
int browserWindowWidth = mainWindow.getBrowserWindowWidth();
subWindow.setPositionX((browserWindowWidth - 700) / 2);
subWindow.setPositionY(190);
hope this may help.