HorizontalLayout has undefined width by default, so it shrinks to the width of the button. You have to set setWidth(“100%”) for it. This probably requires that the form has a defined width (relative or fixed).
The default footer layout in Form is actually a HorizontalLayout, so you just need to use getFooter() and cast it to set the alignment for the button.
Button commit = new Button("OK");
form.getFooter().setWidth("100%");
form.getFooter().addComponent(commit);
((HorizontalLayout)form.getFooter())
.setComponentAlignment(commit, Alignment.TOP_RIGHT);
You shouldn’t be worried about the seemingly fixed sizes that you may observe in FireBug. Many Vaadin layout components, such as HorizontalLayout, calculate widths dynamically in JavaScript on the client-side and set the height and widhts in the HTML DOM. That happens also with relatively sized layouts and layouts with undefined size.
That’s because form has 100% width within it’s containing layout by default. You should set a fixed width for the Form to make it less wide. “form.setWidth(“400px”)”, for example.
You can’t set an undefined width for the form to make it shrink as small as possible, because you have now set the footer layout to 100% width - that would lead to a paradox. That’s actually possible to solve by putting the button
outside the Form into a VerticalLayout and setting undefined width for the form, it’s layout, and for the containing VerticalLayout. In that case, the VerticalLayout gets its width from the form, and the external “footer” can use that width as a reference for 100% width. Did this get complex?
This example demonstrates that technique a bit.
The 100% width for the comes from rather complex logic and it’s not possible to set it directly.
While Firebug is great for the purpose of building themes, you shouldn’t think of the HTML structure too much. Vaadin has complex logic for building the structure and calculating various sizes and it’s not possible to tune every detail in HTML from the API. You shouldn’t really even need to know about HTML when coding with Vaadin, so unless making custom themes with CSS, forget the HTML and concentrate on learning the API.