Unable to use setContent() and addComponent functions

Hi All,

I’m quite new to vaadin and programming in general but I’m having some issues finding and using the setContent() and addComponent functions. Is there anything I would particularly need in order to have these functions?

Hi,

are you using Vaadin 14 version? The method addComponent is from an older version of the framework. It is replaced with a simpler one named : add in Vaadin 10+. A setContent method was previously used (in older versions as well) to assign a content to an element, which can have only one child (such as a UI, window or Panel). For example, a [Details]
(https://vaadin.com/api/platform/14.1.17/com/vaadin/flow/component/details/Details.html) components has this method in the V14 version as well, but generally (if you are using Div, VerticalLayout or HorizontalLayout) you can use the same add method.

What are the elements you are using? :slight_smile:

Best regards,

Anastasia

Hi Anastasia,

Thanks this really helps. I was planning on mainly using verticalLayout and horizontalLayout but now i know i can just use the add method.

Thanks again.

Hi,

glad to hear that it helped :slight_smile: And good luck with the project :slight_smile: