row = new HorizontalLayout();
row.addStyleName("wrapping");
row.setSpacing(true);
addComponent(row);
OptionGroup options = new OptionGroup("Choose one, explicit width");
options.setWidth("200px");
options.addItem("Option One");
Item two = options
.addItem("Option Two, with a longer caption that should wrap when the components width is explicitly set.");
options.addItem("Option Three");
options.select("Option One");
options.setItemIcon("Option One", testIcon.get());
options.setItemIcon(two, testIcon.get());
options.setItemIcon("Option Three", testIcon.get(true));
row.addComponent(options);
options = new OptionGroup("Choose many, explicit width");
options.setMultiSelect(true);
options.setWidth("200px");
options.addItem("Option One");
two = options
.addItem("Option Two, with a longer caption that should wrap when the components width is explicitly set.");
options.addItem("Option Three");
options.select("Option One");
options.setItemIcon("Option One", testIcon.get());
options.setItemIcon(two, testIcon.get());
options.setItemIcon("Option Three", testIcon.get(true));
row.addComponent(options);
options = new OptionGroup("Choose one, small");
options.addStyleName("small");
options.setMultiSelect(false);
options.addItem("Option One");
options.addItem("Option Two");
options.addItem("Option Three");
options.select("Option One");
options.setItemIcon("Option One", testIcon.get());
options.setItemIcon("Option Two", testIcon.get());
options.setItemIcon("Option Three", testIcon.get(true));
row.addComponent(options);
options = new OptionGroup("Choose many, small");
options.addStyleName("small");
options.setMultiSelect(true);
options.addItem("Option One");
options.addItem("Option Two");
options.addItem("Option Three");
options.select("Option One");
options.setItemIcon("Option One", testIcon.get());
options.setItemIcon("Option Two", testIcon.get());
options.setItemIcon("Option Three", testIcon.get(true));
row.addComponent(options);
options = new OptionGroup("Choose one, large");
options.addStyleName("large");
options.setMultiSelect(false);
options.addItem("Option One");
options.addItem("Option Two");
options.addItem("Option Three");
options.select("Option One");
options.setItemIcon("Option One", testIcon.get());
options.setItemIcon("Option Two", testIcon.get());
options.setItemIcon("Option Three", testIcon.get(true));
row.addComponent(options);
options = new OptionGroup("Choose many, large");
options.addStyleName("large");
options.setMultiSelect(true);
options.addItem("Option One");
options.addItem("Option Two");
options.addItem("Option Three");
options.select("Option One");
options.setItemIcon("Option One", testIcon.get());
options.setItemIcon("Option Two", testIcon.get());
options.setItemIcon("Option Three", testIcon.get(true));
row.addComponent(options);
options = new OptionGroup("Horizontal items");
options.addStyleName("horizontal");
options.addItem("Option One");
two = options.addItem("Option Two, with a longer caption");
options.addItem("Option Three");
options.select("Option One");
options.setItemIcon("Option One", testIcon.get());
options.setItemIcon(two, testIcon.get());
options.setItemIcon("Option Three", testIcon.get());
row.addComponent(options);
options = new OptionGroup("Horizontal items, explicit width");
options.setMultiSelect(true);
options.setWidth("500px");
options.addStyleName("horizontal");
options.addItem("Option One");
two = options.addItem("Option Two, with a longer caption");
options.addItem("Option Three");
options.select("Option One");
options.setItemIcon("Option One", testIcon.get());
options.setItemIcon(two, testIcon.get());
options.setItemIcon("Option Three", testIcon.get());
row.addComponent(options);
}