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.
Show subwindow below a component
How can I show the subWindow based on component position??
I have a button Logout and want show the "cambiar contraseña" subwindow below it, like profile in gmail.
I am searching the position X & Y of the button but I don´t find it.
I tried using the width of the navigation window (resizable) to locate this position but do not get it.
@SuppressWarnings("serial")
public class ChangePasswordSubwindow extends Window {
public ChangePasswordSubwindow(int positionX, int positionY) {
this.setCaption("Cambiar contraseña");
this.setModal(true);
this.setDraggable(false);
this.setResizable(false);
this.setPositionX(positionX);
this.setPositionY(positionY);
// Configure the windws layout; by default a VerticalLayout
VerticalLayout layout = (VerticalLayout) this.getContent();
layout.setMargin(true);
layout.setSpacing(true);
layout.setSizeUndefined();
}
}
(...)
ChangePasswordSubwindow changePasswordSubwindow = new ChangePasswordSubwindow(event.getRelativeX(), event.getRelativeY() + 10);
if (changePasswordSubwindow.getParent() != null) {
// window is already showing
getWindow().showNotification(
"La ventana está abierta");
} else {
// Open the subwindow by adding it to the parent
// window
getWindow().addWindow(changePasswordSubwindow);
}
Any help?
Thanks.
I'm not sure if there is any nice way to get the screen coordinates of a component on the server-side. You could consider using a Panel with a CustomOverlay in the Overlays add-on. Or the regular PopupView, with perhaps a Panel as the content, and then style the minimized view as a button.
Not sure how the add-on PopupButton does it, but it positions a layout of your choice under a button when it's clicked. At the very least, the code for it might help you come up with a solution.