Form Button Alignment

I can’t seem to right-align the buttons in the footer of one of my Forms. I followed the example in the book but the buttons are always left aligned. I am sure I am missing something very obvious but I just can’t seem to find it. Below is the code I am using. Thanks!


		Form loginForm = new Form();
		loginForm.setWriteThrough(false);
		loginForm.setInvalidCommitted(false);

		loginForm.setFormFieldFactory(new LoginFieldFactory());
		loginForm.setItemDataSource(loginFormItem);

		loginForm.setVisibleItemProperties(Arrays.asList(new String[] {"userName", "password" }));
		
		HorizontalLayout buttons = new HorizontalLayout();
		buttons.setSizeFull();
        buttons.setSpacing(true);
        
        Button loginButton = new Button("Login");
        buttons.addComponent(loginButton);
        buttons.setComponentAlignment(loginButton, Alignment.TOP_RIGHT);
        
        loginForm.getFooter().addComponent(buttons);

I got it to work by explicitly setting the width of the HorizontalLayout but I didn’t think I had to do that. Shouldn’t the width of that default to the width of the form? It’s not set in the example in the book either.

Thanks,
Steve