The Vaadin 7 book for CustomComponent has Panel.addComponent. I believe it is not supported in Vaadin 7
What do you mean by “is not supported”?
panel.addcomponent(“”) references a component of type panel named “panel”.
Is the code you mean this?
Panel panel = new Panel("My Custom Component");
panel.setContent(new VerticalLayout());
// Compose from multiple components
Label label = new Label(message);
label.setSizeUndefined(); // Shrink
panel.addComponent(label);
panel.addComponent(new Button("Ok"));
panel.addComponent has nothing to do with the CustomComponent class.
In the code snippet it creates a new component of type Panel and adds a label and button to it.
After that it sets the Composition-Root of the CustomComponent to the panel which means that now the class holds holds the panel and all it’s children.
“Typically, you simply combine existing built-in components to produce composite components.”
So when you do something like this in another class:
MyComposite comp = new MyComposite();
someLayout.addComponent.addComponent(comp);
It adds the panel + button + label… to the somelayout.
In Vaadin 7, Panel is a SingleComponentContainer and you should use setContent() instead of addComponent.
There’s still some outdated examples, fixing them one by one. Thanks for noting, fixing that one right away.