Search code examples
vaadin7

CheckBox caption position in FormLayout (Vaadin 7.5.0)


I have a problem with the FormLayout and the CheckBox component. I want to use the FormLayout to generate a form for the user. This means I want to have all options in the form (Textinput, Numberinput, Options...) aligned by the Formlayout with the caption to the left and the input to the right.

This works well with other components but not with CheckBox. It always places its caption to the right of the Box, which breaks the visual order of my form.


Solution

  • In Vaadin, the implementation of a component can decide if it renders its caption by itself or if its parent, a component container, renders it. Most of the components let the parent to render the caption. CheckBox is a component that renders its caption by itself.

    To fix the problem, you could wrap your CheckBox inside a layout (CssLayout for example) and set the caption for the layout, or you could use this addon: FormCheckBox.