2

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.

  • Your Question is not clear. Do you mean that you have initially designed a view with Vaadin Designer, then at runtime you want to alter that view by adding widgets? I suggest you edit your Question to be more brief, and get directly to the point. – Basil Bourque Apr 25 '23 at 19:10
  • "but it hasn't worked either" what does that mean? – cfrick Apr 26 '23 at 14:43
  • I edited the post and tried to explain it better, my apologies. I hope it's clearer now. – LucaDanielG Apr 27 '23 at 08:23

0 Answers0