Alignment in Vaadin
java, vaadin
Solution
The reason for the components appering to be aligned to the top is that you haven't specified a height for your VerticalLayouts. When you don't specify a size for a layout, its size is determined by the child components it contains. In such a case, setting the alignment won't make any difference, as there's no extra room inside the layout's slots.
Set the size, using e.g. `layout.setHeight("100%");` or `layout.setSizeFull();` and you should notice the difference immediately.
Problem
I have the following piece of code that I wrote in Vaadin. The problem is that the alignment does not work. I set it to bottom_center, but the components are all stuck to the top (top_center) of my web browser. Can anyone help me out with this? Thanks! ``` VerticalLayout layout = new VerticalLayout(); VerticalLayout layout1 = new VerticalLayout(); Panel panel = new Panel(); panel.setWidth("500px"); panel.setHeight("300px"); Button button = new Button("Enter"); Button login = new Button("Login"); layout1.addComponent(textfield); layout1.addComponent(button); layout1.addComponent(login); layout.addComponent(panel); layout.setComponentAlignment(panel, Alignment.BOTTOM_CENTER); layout1.setComponentAlignment(textfield, Alignment.BOTTOM_CENTER); layout1.setComponentAlignment(login, Alignment.BOTTOM_CENTER); layout1.setComponentAlignment(button, Alignment.BOTTOM_CENTER); ```