Limit moving range of a window to a component

Is it possible to limit the moving range of a window to a component?

Let’s say, I have a top component with some menu and below a work area.
Now I want to add some windows to this work area. But they should be contained within this work area.
Is there a way to achive this?


Hey Sascha,

Unfortunately there’s no ready-made solution for this in Vaadin. I remembered that there’s a ticket about not allowing windows to be dragged outside of the browser window, but I couldn’t find that one. And it wouldn’t have solved your problem anyway, only showed you how to implement it yourself.

I’m afraid you’re stuck extending the Window and VWindow classes creating your own Window. In VWindow the code you need to change is pretty simple, you just need to set upper and lower limits for the x and y variables in this method:

public class VWindow extends VOverlay implements Container, ScrollListener {
    private void onDragEvent(Event event) {
        switch (DOM.eventGetType(event)) {
        case Event.ONMOUSEMOVE:
            if (dragging) {
                centered = false;
                final int x = DOM.eventGetScreenX(event) - startX + origX;
                final int y = DOM.eventGetScreenY(event) - startY + origY;
                setPopupPosition(x, y);

You can then extend the Window class adding methods for providing the upper and lower limits for x and y.

Hope this will get you started!

Thanks, but I’m currently just evaluating Vaadin and therefore wanted to know if there is a solution for this.
As I see now there is some work to do and maybe using subwindows in a subwindow can do the trick. Then I only would have to position the top-subwindow and hide it’s title bar and borders so it will look like a panel.
If I get the time to try this out, I will report.

Unfortunately almost everything in VWindow is private, so it’s not simple to override.
So am I stuck with changing the Vaadin code itself?

Apparently you’re correct about everything being private :frowning:

Looks like the easiest path is to patch the Vaadin code. If you do this, please submit the patch to our R&D team (via
) and they’ll see if they can incorporate it in the next release of Vaadin.

If anyone knows an easier way to get this done, please chime in!


Okay, I’ve done the patching. I created the
Ticket #3085
for this. The affected vaadin files are attached.

Basically I added a bounding value for each side. The window is then checked to stay inside while been dragged or resized. This behaviour can be enabled. Default is disabled to keep the “backward” compatibility.

In the progress I also added a “draggingEnabled” feature to have a window stationary.

As for now the limitation is such, that when the window is created it can exceed it’s bounds, e.g. when using relative sizes and center().

Hi Sascha,

I am looking for this feature and very happy to see this!! But after tried, it doesn’t work for me.

I’ve modified Window and VWindow classes in vaadin-6.1.5.jar (my version is 6.1.5)

But When I add a Window within an Application and try to control its bounds, there is no effect. Is there anything I need to do to make it happen?

below is my code:

Hi Sasha,
it seems that your ticket had been forgotten !!!
Your patch is not applicable to vaadin 7 and I need it.
I am working on a custom widget which consists of a rezisablepanel that can be dragged resized only in its parent component.
Does anybody knowns if it exists already ?