Search code examples
javacsswebvaadinform-layout

replacing cells of formlayout in vaadin


when i am using formlayout in vaadin with text fields it make the caption on text field at left to the text field , what about if i need the caption in right of text field

FormLayout fieldsLayout = new FormLayout();
    TextField userNameFld = new TextField("User Name:", true);
    userNameFld.setIcon(FontAwesome.USER);
    fieldsLayout.addComponent(userNameFld);
    PasswordField passwordFld = new PasswordField("Password:", true);
    fieldsLayout.addComponent(passwordFld);
    TextField companyFld = new TextField("Company Name:", true);
    fieldsLayout.addComponent(companyFld); 

how can i replace the positions of caption and textfields


Solution

  • FormLayout has three columns: first for caption, second (middle) for error indicator and third for component (for example TextField). And this is fixed construction.

    To change order of those columns you must build your own layout using one VerticalLayout and some HorizontalLayout for each row. In each row you could add TextField without caption and one Label on the right position.