Positioning of the component which is added late to AbsoluteLayout

Dear Vaadin users,

I experience the following problem with
AbsoluteLayout
: I would like to show the
PopupView
on layout mouse click. Here is the code for the listener:

PopupView popupViewComponent = null;

/**
 * @see com.vaadin.event.LayoutEvents.LayoutClickListener#layoutClick(com.vaadin.event.LayoutEvents.LayoutClickEvent)
 */
public void layoutClick(LayoutEvents.LayoutClickEvent event) {
	// Remove the previous one, if any:
	if (popupViewComponent != null) {
		layout.removeComponent(popupViewComponent);
	}

	PopupView popupViewComponent = new ...;

	layout.addComponent(popupViewComponent);

	ComponentPosition position = layout.getPosition(popupViewComponent);

	position.setLeft(Float.valueOf(event.getRelativeX()), UNITS_PIXELS);
	position.setTop(Float.valueOf(event.getRelativeY()), UNITS_PIXELS);

	popupViewComponent.setPopupVisible(true);
}

What is happening: the popup is shown, but always at position (0, 0) i.e. leftmost top position of the window (even not the layout). I’ve double checked the mouse coordinates: they are not zero.

P.S. The contents of the popup depends on the mouse position.

i’m just curious why you did not use event.getClientX() and event.getClientY() instead.

This is because I need mouse position relative to the top-left corner of the layout. In my case I would like to work with mouse coordinates and UI components relative to the layout.

The root of the problem was found: I’ve accidentally
v-popupview { display: inline; }
CSS style to popups, thus making them not popups at all…