TextField tf;
VerticalLayout vl;
CssLayout cssLayout = new CssLayout() {
@Override
protected String getCss(Component c) {
return "margin-top: 20px; background:red;";
}
};
vl = new VerticalLayout();
vl.setHeight("40px");
vl.setWidth("200px");
tf = new TextField();
tf.setSizeFull();
vl.addComponent(tf);
vl.setCaption("Fullsize textfield in 40px height 200px width box");
cssLayout.addComponent(vl);
vl = new VerticalLayout();
vl.setHeight("40px");
vl.setWidth("200px");
TextArea ta = new TextArea();
ta.setRows(2); // make it text area, instead of oneliner
ta.setSizeFull();
vl.addComponent(ta);
vl.setCaption("Fullsize textarea in 100px height 200px width box");
cssLayout.addComponent(vl);
vl = new VerticalLayout();
vl.setSizeUndefined();
tf = new TextField();
vl.addComponent(tf);
vl.setCaption("Normal textfield in natural size.");
cssLayout.addComponent(vl);
getLayout().addComponent(cssLayout);
}