Vaadin 7 RC1 - Label Alignment

Hi folks,

I was trying to align my label along with an image into a HorizontalLayout. The label (which is the first component of the layout) needs to be aligned on the middle right and the image on the middle left. See the snippet:

public class PageNotFoundView extends VerticalLayout implements View {
	public PageNotFoundView () {		
		HorizontalLayout horizontalLayout = new HorizontalLayout();
		Label ops = new Label("OPS! Page not found.");
		String imagePath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();
		FileResource brasaoResource = new FileResource(new File(imagePath + "/WEB-INF/img/brasao.png"));
		Embedded brasao = new Embedded(null, brasaoResource);
		horizontalLayout.setComponentAlignment(ops, Alignment.MIDDLE_RIGHT);
		horizontalLayout.setComponentAlignment(brasao, Alignment.MIDDLE_LEFT);
		setComponentAlignment(horizontalLayout, Alignment.MIDDLE_CENTER);
	public void enter(ViewChangeEvent event) {
		// TODO Auto-generated method stub

The label aligns vertically but not horizontally, so the alignment RIGHT or CENTER does not works for the label component. For the image all the alignments are ok.

I checked in the Chrome F12 feature and the class v-align is not added to the div that holds the label like occurs on the image’s div.

Is it a RC1 layout issue or a common behavior?

Thanks in advance.

The label is by default 100% wide so aligning it horizontally won’t automatically work. Try doing

Thanks John! Works like a charm. :lol: