Custom Component in SubWindow

Hi!

I created a custom component in component editor. I would like to put it into a subwindow. The subwindow appear but it is empty. What am I doing wrong?

The application:


package com.example.xapplication;

import com.vaadin.Application;
import com.vaadin.ui.*;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;

import com.example.xapplication.help.*;

@SuppressWarnings("serial")
public class Xapplication extends Application implements
	        ClickListener {

    private Button help = new Button("Help");

    private HelpWindow helpWindow = null;
    
	public void init() {
		Window mainWindow = new Window("Xaddresbook Application");

        help.addListener((ClickListener) this);
		mainWindow.addComponent(help);

		setMainWindow(mainWindow);
	}

	public void buttonClick(ClickEvent event) {
        showHelpWindow();
	}

    private void showHelpWindow() {
        getMainWindow().addWindow(getHelpWindow());
    }
	
    private HelpWindow getHelpWindow() {
        if (helpWindow == null) {
            helpWindow = new HelpWindow();
        }
        return helpWindow;
    }
	
}

The SubWindow:


package com.example.xapplication.help;

import com.vaadin.ui.Window;

@SuppressWarnings("serial")
public class HelpWindow extends Window {

    public HelpWindow() {
        setCaption("Window");

        HelpWindowLayout helpWin = new HelpWindowLayout();
        addComponent(helpWin);
    }
}

The CustomComponent:


package com.example.xapplication.help;

import com.vaadin.annotations.AutoGenerated;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.CustomComponent;

public class HelpWindowLayout extends CustomComponent {

	@AutoGenerated
	private AbsoluteLayout mainLayout;
	@AutoGenerated
	private Button button_1;

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	/**
	 * The constructor should first build the main layout, set the
	 * composition root and then do any custom initialization.
	 *
	 * The constructor will not be automatically regenerated by the
	 * visual editor.
	 */
	public HelpWindowLayout() {
		buildMainLayout();
		setCompositionRoot(mainLayout);

		// TODO add user code here
	}

	@AutoGenerated
	private AbsoluteLayout buildMainLayout() {
		// common part: create layout
		mainLayout = new AbsoluteLayout();
		mainLayout.setImmediate(false);
		mainLayout.setWidth("100%");
		mainLayout.setHeight("100%");
		mainLayout.setMargin(false);
		
		// top-level component properties
		setWidth("100.0%");
		setHeight("100.0%");
		
		// button_1
		button_1 = new Button();
		button_1.setCaption("Button");
		button_1.setImmediate(true);
		button_1.setWidth("-1px");
		button_1.setHeight("-1px");
		mainLayout.addComponent(button_1, "top:20.0px;left:20.0px;");
		
		return mainLayout;
	}

}

Thanks!

I found the answer in
this article