Form buttons position

Hi
I have a window and a form inside. (See picture)
Here is how I add the buttons to the form:

	private void locateFormButtons(final Form form,final Button okButton,final Button cancelButton) {
		form.getFooter().addComponent(okButton);
		form.getFooter().addComponent(cancelButton);
		final Layout footer = form.getFooter();
		if(footer instanceof HorizontalLayout) {
			((HorizontalLayout) footer).setSpacing(true);
		}		
	}

I want to locate the buttons in the lower right side of the form (See picture).
I have tried different Alignment “games” but it did not work.
Example:

			((HorizontalLayout) footer).setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT); 

Any advice?

Thanks

Avishay
12111.jpg

Hi
I gave the topic another try.
The idea was to create a layout on the form footer and add the buttons to this layout, and align it to the bottom right.
Code:


private void locateFormButtons(final Form form,final Button okButton,final Button cancelButton) {
		final Layout footer = form.getFooter();
		footer.setWidth("100%");
		HorizontalLayout buttonsLayout = new HorizontalLayout();
		buttonsLayout.setWidth("100%");
		buttonsLayout.setSpacing(true);
		buttonsLayout.addComponent(okButton);
		buttonsLayout.addComponent(cancelButton);
		footer.addComponent(buttonsLayout);
		if(footer instanceof HorizontalLayout) {
			HorizontalLayout layout = (HorizontalLayout) footer;
			layout.setComponentAlignment(buttonsLayout, Alignment.BOTTOM_RIGHT);
		}		
	}

Visual result: (not the wanted result…)

Please advice.

Thanks
Avishay
12130.png

Hi,

You’re almost there with your second attempt - the problem is that “buttonsLayout” should have an undefined width. The following should work (but I haven’t tried it)

private void locateFormButtons(final Form form,final Button okButton,final Button cancelButton) {
        HorizontalLayout buttonsLayout = new HorizontalLayout();
        buttonsLayout.setWidth(null)
        buttonsLayout.setSpacing(true);
        buttonsLayout.addComponent(okButton);
        buttonsLayout.addComponent(cancelButton);

        final Layout footer = form.getFooter();
        footer.setWidth("100%");
        footer.addComponent(buttonsLayout);
        if(footer instanceof HorizontalLayout) {
            HorizontalLayout layout = (HorizontalLayout) footer;
            layout.setComponentAlignment(buttonsLayout, Alignment.BOTTOM_RIGHT);
        }        
    }

Cheers,

Charles

Thanks Charles.
It looks much better now. (See attachment)
The last thing is that I want to push those buttons down - I want them to be at the bottom of the dialog.

Any idea?

Thanks

Avishay
12132.png