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 add a Vertical SrollBar to VerticalLayout
VerticalLayout mainLayout = new VerticalLayout ();
mainLayout.setSizeFull();
GridLayout content= getCenterContent();
mainLayout.addComponent(content);
mainLayout.setComponentAlignment(content, Alignment.TOP_CENTER);
-----
-----
public GridLayout getCenterContent() {
GridLayout layout = new GridLayout(1, 50);
layout.addComponent(new Label("Text"));
layout.addComponent(new Label("Text"));
layout.addComponent(new Label("Text"));
layout.addComponent(new Label("Text"));
----
----
return layout;
}
Here 'content' has more component. Only way to see all, a vertical scroll bar is required. How it possible to see.
don't have mainLayout as setSizeFull(). that means that the height is calculated to a pixel amount, and everything outside that pixel amount is cut out. The default (setWidth("100%"); setHeight(null);) is good for you, so just remove that row. This will work if you have it inside something that supports scrolling, like the main window. If this layout is inside another layout, then it won't scroll. To get around this problem, use a Panel as that supports scrolling (mainWindow is in fact a sort of a panel). Create a new Panel, set the panel to setSizeFull(); and set the layout as content (setContent(mainLayout).
Nick Barron: thanks, that helped me
Arun R T: VerticalLayout mainLayout = new VerticalLayout ();
mainLayout.setSizeFull();GridLayout content= getCenterContent();
mainLayout.addComponent(content);
mainLayout.setComponentAlignment(content, Alignment.TOP_CENTER);-----
-----public GridLayout getCenterContent() {
GridLayout layout = new GridLayout(1, 50);
layout.addComponent(new Label("Text"));
layout.addComponent(new Label("Text"));
layout.addComponent(new Label("Text"));
layout.addComponent(new Label("Text"));
----
----
return layout;
}Here 'content' has more component. Only way to see all, a vertical scroll bar is required. How it possible to see.
add this to css style of the layout
You can use Layouts instead of Panels
overflow: auto !important;
I have my own grid declared as
public class MyGrid extends Grid{}
I am getting records for the grid from the database. As the number of records grow in size, I am not able to see all the rows as I am not getting the vertical scroll bar.
So, I added the grid to a Panel, so that when contents overflows panel will automatically add vertocal scrollbar. But unfortunately I am not getting the Vertical Scroll bar.
private Panel taskInfoPanel;
private MyGrid checklistTaskInfo;
taskInfoPanel = new Panel();
taskInfoPanel.setHeight(400.0f, Unit.PIXELS);
checklistTaskInfo = new MyGrid(gpc);
checklistTaskInfo.setImmediate(true);
taskInfoPanel.setContent(checklistTaskInfo);
How can I get a vertical scroll bar?
Thanks...