Java Code Examples for com.vaadin.ui.Component#setHeight()

The following examples show how to use com.vaadin.ui.Component#setHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebComponentsHelper.java    From cuba with Apache License 2.0 5 votes vote down vote up
public static void expand(AbstractOrderedLayout layout, Component component, String height, String width) {
    if (!isHorizontalLayout(layout)
            && (StringUtils.isEmpty(height) || AUTO_SIZE.equals(height) || height.endsWith("%"))) {
        component.setHeight(100, Sizeable.Unit.PERCENTAGE);
    }

    if (!isVerticalLayout(layout)
            && (StringUtils.isEmpty(width) || AUTO_SIZE.equals(width) || width.endsWith("%"))) {
        component.setWidth(100, Sizeable.Unit.PERCENTAGE);
    }

    layout.setExpandRatio(component, 1);
}
 
Example 2
Source File: MVerticalLayout.java    From viritin with Apache License 2.0 5 votes vote down vote up
/**
 * Expands selected components. Also adds to layout and sets the only sane
 * height for expanded components (100%) if needed.
 *
 * @param componentsToExpand components that should be expanded
 * @return the object itself for further configuration
 */
public MVerticalLayout expand(Component... componentsToExpand) {
    if (getHeight() < 0) {
        // Make full height if no other size is set
        withFullHeight();
    }
    for (Component component : componentsToExpand) {
        if (component.getParent() != this) {
            addComponent(component);
        }
        setExpandRatio(component, 1);
        component.setHeight(100, Unit.PERCENTAGE);
    }
    return this;
}
 
Example 3
Source File: SimpleBoxFormBuilder.java    From jdal with Apache License 2.0 4 votes vote down vote up
/**
 * Builds the panel form.
 * @return the form component
 */
public Component getForm() {
	
	for (int i = 0; i < columns.size(); i++) {
		VerticalLayout box = columns.get(i);
		int width = columnsWidth.get(i);
		
		if (width > SIZE_UNDEFINED && width < SIZE_FULL) {
			box.setWidth(width, Unit.PIXELS);
			// shrink container
			container.setExpandRatio(box, 0);
		}
		else if (width == SIZE_FULL) {
			box.setWidth("100%");
			container.setExpandRatio(box, 1);
		}
		else {
			container.setExpandRatio(box, 0);
			box.setWidth(Sizeable.SIZE_UNDEFINED, Unit.PIXELS);
		}
		
		for (int j = 0; j < rowsHeight.size(); j++) {
			Component c = box.getComponent(j);
			int height = rowsHeight.get(j);

			if (height > SIZE_UNDEFINED &&  height < SIZE_FULL) {
				c.setHeight(height, Unit.PIXELS);
				box.setExpandRatio(c, 0);
			}
			else if (height == SIZE_FULL) {
				c.setHeight("100%");
				box.setExpandRatio(c, 1);
			}
			else {
				box.setExpandRatio(c, 0);
			}
		}
	}
	
	if (fixedHeight) {
		container.setHeight(getFormHeight(), Unit.PIXELS);
	}
	else {
		container.setHeight(100, Unit.PERCENTAGE);
	}
	
	if (fixedWidth) {
		container.setWidth(Sizeable.SIZE_UNDEFINED, Unit.PIXELS);
	}
	else {
		container.setWidth(100, Unit.PERCENTAGE);
	}

	container.addStyleName("jd-box");
	
	if (debug)
		container.addStyleName("jd-box-debug");
	
	return container;
}