Window [addComponent] Problem

In Window, using addComponent() method does not align the component Top. But setContent() align Top align.

is possible setComponentAlignment() in Window

Window contains by default a VerticalLayout with margins enabled.
And the 2 functions do completely different things.

When you do setContent() you actually replace that VerticalLayout by your own component (which removes the margins)

But when you do addComponent() you are actually adding to the inner VerticalLayout (which has margins)

If you want to keep the original layout of the window without the margins you can do :

((VerticalLayout)window.getContent()).setMargins(false);

So the margins are disabled

Or simply set a new root layout yourself :

window.setContent(new VerticalLayout());

I’d guess you have been reading the Book of Vaadin version for Vaadin 6 and not for Vaadin 7. In Vaadin 7, Panel has setContent() but not addComponent(), and you need to set a layout as its content if you want to add multiple components there.