I am finding some problems when trying to add a Component to a Vaadin vertical layout. I have initially designed a Vaadin view using Vaadin Designer, dragging and dropping elements. Now, from a Java class which inheritates the java class of the Vaadin view, I need to add a new component to a vertical layout of that view.
I was trying to do that by getting first de layout with its own getter and then adding the new component using add(Component component)
like this (the component is actually another Vaadin view with a layout and a button inside it):
this.getVaadinVerticalLayout3().as(VerticalLayout.class).add(_ver_seguidos);
But this way the component is added below the components of the layout and I want it to be the first. Here is what I'm meaning: I want the component to be added above the number label, not below it. The following picture shows what I'm getting vs what I'm expected to:
I have already tried addComponentAtIndex(int index, Component component)
, where you can specify the position you'd like it to take (in my case, the index would be 0 to put it above all layout's elements), but it hasn't worked.
Another way I was suggested to try was using addComponentAsFirst(Component component)
, but it hasn't worked neither.
How could I add this element and place it above all existing elements in the layout without using Vaadin Designer? I would appreciate any help and advice, thank you in advance.
My IDE: Eclipse 2021-03, and Vaadin Version: 4.6.20.