Example usage for com.vaadin.ui Component setWidth

List of usage examples for com.vaadin.ui Component setWidth

Introduction

In this page you can find the example usage for com.vaadin.ui Component setWidth.

Prototype

public void setWidth(float width, Unit unit);

Source Link

Document

Sets the width of the object.

Usage

From source file:org.jdal.vaadin.ui.form.SimpleBoxFormBuilder.java

License:Apache License

public void add(Component c, String label, int width, Alignment alignment) {
    if (rows == 0 && rowsHeight.isEmpty()) {
        log.warn("You must call row() before adding components. I will add a row with default height for you");
        row();/*from  ww  w .  ja va 2 s  .com*/
    }

    if (label != null)
        c.setCaption(label);

    VerticalLayout column = getColumn();
    column.addComponent(c);
    index++;

    setWidth(width);

    if (alignment != null) {
        column.setComponentAlignment(c, alignment);
    }

    if (rowCellSpand) {
        c.setWidth(100, Unit.PERCENTAGE);
    }

    if (useTabIndex && c instanceof Field) {
        ((Field<?>) c).setTabIndex(tabIndex++);
    }
}

From source file:org.lucidj.renderer.DefaultObjectRenderer.java

License:Apache License

private void apply_renderer(Object obj) {
    Component new_component = null;

    log.info("apply_renderer: obj={}", obj);
    current_object = obj;//from   w w w. j  av a2 s .  c  o m

    if (obj == null) {
        // Will use the default component to display 'null'
        current_renderer = null;
    } else if ((current_renderer = renderer_factory.locateAndBindRenderer(this, obj)) != null) {
        // Issue initial update
        current_renderer.objectUpdated();
        new_component = current_renderer.renderingComponent();
    }

    // Fallback to default renderer if we fail to get proper renderer or its instance
    if (current_renderer == null) {
        default_component.setValue(obj == null ? "null" : obj.getClass().getSimpleName());
        new_component = default_component;
    }

    if (current_component != null) {
        // Copy current component dimensions
        new_component.setWidth(current_component.getWidth(), current_component.getWidthUnits());
        new_component.setHeight(current_component.getHeight(), current_component.getHeightUnits());
    }

    current_component = new_component;
    setCompositionRoot(new_component);

    log.info("apply_renderer: current_renderer={} current_component={}", current_renderer, current_component);
}

From source file:org.primaldev.ppm.util.ChartTypeComponent.java

License:Apache License

public void addChart(String description, Component chart, String errorMessage) {

    addComponent(new Label("&nbsp;", ContentMode.HTML));
    addComponent(new Label("&nbsp;", ContentMode.HTML));

    // Description
    if (description != null) {
        Label label = new Label(description);
        label.addStyleName(Reindeer.LABEL_H2);
        addComponent(label);//from  w  w w.j  a va  2  s.  c om

        addComponent(new Label("&nbsp;", ContentMode.HTML));
    }

    // Chart
    if (chart != null) {
        if (chart instanceof DCharts) {
            // DCharts doesn't know how to size itself
            chart.setWidth(400, Unit.PIXELS);
            chart.setHeight(250, Unit.PIXELS);
            ((DCharts) chart).show();
        }
        addComponent(chart);
    }

    // Error message
    if (errorMessage != null) {
        Label errorLabel = new Label(errorMessage);
        addComponent(errorLabel);
    }
}