public void recalculateExpandRatios() { for (Iterator<Component> it = getComponentIterator(); it.hasNext(); ) { setExpandRatio(it.next(), 0.0f); } if (getComponentCount() > 0) { if (alignment.isLeft()) { setExpandRatio(getComponent(getComponentCount() - 1), 1.0f); } else if (alignment.isRight()) { setExpandRatio(getComponent(0), 1.0f); } } } }
public static HorizontalLayout horizontalLayout(Alignment alignment, com.vaadin.ui.Component... components) { HorizontalLayout hl = new HorizontalLayout(); hl.setWidth(100, Sizeable.UNITS_PERCENTAGE); hl.setSpacing(true); if (components != null && components.length > 0) { for (com.vaadin.ui.Component c : components) { hl.addComponent(c); hl.setComponentAlignment(c, alignment); } if (alignment.isRight()) { hl.setExpandRatio(hl.getComponent(0), 1.0f); } else if (alignment.isLeft()) { hl.setExpandRatio(hl.getComponent(hl.getComponentCount() - 1), 1.0f); } } return hl; }