Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
How to set auto scroll to panel
Hi sir ,
In my vaadin application , i need to set scrollbar to panel which contains verticallayout which contains absolutelayout.
I set the panel as setScrollable(true) and setScrolltop(1600). what the problem is that i have changed the height of the both verticallayout and
absolutelayout greater than panel height . That's why panel creating scrollbar . If i reduce the height of vertical and absolutelayout
to lower than panel height, then scroll in panel disappear. Please give some solution.
This is my code
private Panel buildPanel_2()
{
// common part: create layout
panel_2 = new Panel();
panel_2.setImmediate(true);
panel_2.setHeight("700px");
panel_2.setScrollable(true);
panel_2.setScrollTop(1600);
verticalLayout_2 = buildVerticalLayout_2();
panel_2.setContent(verticalLayout_2);
return panel_2;
}
@AutoGenerated
private VerticalLayout buildVerticalLayout_2()
{
// common part: create layout
verticalLayout_2 = new VerticalLayout();
verticalLayout_2.setImmediate(true);
verticalLayout_2.setMargin(false);
verticalLayout_2.setWidth("1000px");
verticalLayout_2.setHeight("2000px");
absoluteLayout_5 = buildAbsoluteLayout_5();
verticalLayout_2.addComponent(absoluteLayout_5);
return verticalLayout_2;
}
@AutoGenerated
private AbsoluteLayout buildAbsoluteLayout_5()
{
// common part: create layout
absoluteLayout_5 = new AbsoluteLayout();
absoluteLayout_5.setImmediate(false);
absoluteLayout_5.setWidth("1000px");
absoluteLayout_5.setHeight("2000px");
absoluteLayout_5.setMargin(false);
//
return absoluteLayout_5;
}
Thank you sir.
I don't see what you problem is. What does you application do and what would you like it to do instead?
Panel is by design working so that if the content is bigger than the panel, then it will show scrollbars, else the scrollbars will not be there. If you want to override that, you'd have to force a overflow-y: scroll style to the .v-panel-content element of the panel. Because another overflow value is defined as an inline style, you'd need to use !important to force the new overflow-y into effect.
Hi sir ,
You are correct ,if i add the content directly to panel then it shows scrollbar.
Actually my content is added the absoluteLayout which is added to verticallayout which is added to panel. My content is not directly added to panel.
How do i set width and height of the absoluteLayout and verticalLayout and Panel which shows auto scrollbar.
Thank you.
If you set the height of the VerticalLayout to anything smaller, then there is nothing to scroll so there will be no scrollbars.
You need to set the height of the VerticalLayout to SIZE_UNDEFINED so it will take the height of its contents. Then, if its contents height is greater than the Panel size, it will show scrollbars.