Div does not fit embedded UI

I followed the tutorial in the Book of Vaadin for embedding UIs in Web Pages. Everything works fine when the UI does not implement ViewChangeListener and has a navigator. When it dows, the div element to embed the UI does not expand to fit UI content in Chrome and Firefox. In IE, it works. When not embedded in a Web page, everything is fine in all browsers.

Here is my UI code:

public class MyUI extends UI implements ViewChangeListener {

    Navigator navigator;

    protected void init(VaadinRequest request) {
        getSession().setLocale(new Locale("pt", "BR"));
        VerticalLayout layout = new VerticalLayout();
        Panel view = new Panel();
        layout.setComponentAlignment(view, Alignment.TOP_CENTER);
        navigator = new Navigator(this, view);
        navigator.addView("", new MainView());
    public boolean beforeViewChange(ViewChangeEvent event) {
        return true;

    public void afterViewChange(ViewChangeEvent event) {


Is there anything wrong?