Vaadin – How to make Alignment combobox with button.

Good Day!

Title : Vaadin – How to make Alignment combobox with button.

1.The button are not align with combobox , where button are hanging on the top if we using HorizontalLayout , so my solution is using  GridLayout.

  • added with : grid.setComponentAlignment(btnSubmit,Alignment.BOTTOM_LEFT);

2. From Image  A to Image B.

3. Image A

howtosetalignthecomboboxandbutton2.jpg

To 

4. Image B

howtosetalignthecomboboxandbutton.jpg

5. The source Code.

protected void init(VaadinRequest request) {

final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);

GridLayout grid = new GridLayout(3,1);
Button btnSubmit = new Button(“Submit“);
combofirst= createFirstComboSelect(); // state combobox
combosecond = createSecondComboSelect(); // district combobox
grid.setSpacing(true);
grid.setSizeFull();
grid.setSizeUndefined();
grid.addComponent(combofirst);
grid.addComponent(combosecond);
grid.addComponent(btnSubmit);
/***java.lang.IllegalArgumentException: Component must be added to layout before using setComponentAlignment() ***/
grid.setComponentAlignment(btnSubmit,Alignment.BOTTOM_LEFT);
layout.addComponent(grid);
}

6. Full source codes project can get from My Github.

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s