createForm2();
add(vp);
}
private void createForm1() {
FormPanel simple = new FormPanel();
simple.setHeading("Simple Form");
simple.setFrame(true);
simple.setWidth(350);
TextField<String> firstName = new TextField<String>();
firstName.setFieldLabel("Name");
firstName.setAllowBlank(false);
firstName.getFocusSupport().setPreviousId(simple.getButtonBar().getId());
simple.add(firstName, formData);
TextField<String> email = new TextField<String>();
email.setFieldLabel("Email");
email.setAllowBlank(false);
simple.add(email, formData);
List<Stock> stocks = TestData.getStocks();
Collections.sort(stocks, new Comparator<Stock>() {
public int compare(Stock arg0, Stock arg1) {
return arg0.getName().compareTo(arg1.getName());
}
});
ListStore<Stock> store = new ListStore<Stock>();
store.add(stocks);
ComboBox<Stock> combo = new ComboBox<Stock>();
combo.setFieldLabel("Company");
combo.setDisplayField("name");
combo.setTriggerAction(TriggerAction.ALL);
combo.setStore(store);
simple.add(combo, formData);
DateField date = new DateField();
date.setFieldLabel("Birthday");
simple.add(date, formData);
TimeField time = new TimeField();
time.setFieldLabel("Time");
simple.add(time, formData);
Slider slider = new Slider();
slider.setMinValue(40);
slider.setMaxValue(90);
slider.setValue(60);
slider.setIncrement(1);
slider.setMessage("{0} inches tall");
final SliderField sf = new SliderField(slider);
sf.setFieldLabel("Size");
simple.add(sf, formData);
CheckBox check1 = new CheckBox();
check1.setBoxLabel("Classical");
CheckBox check2 = new CheckBox();
check2.setBoxLabel("Rock");
check2.setValue(true);
CheckBox check3 = new CheckBox();
check3.setBoxLabel("Blue");
CheckBoxGroup checkGroup = new CheckBoxGroup();
checkGroup.setFieldLabel("Music");
checkGroup.add(check1);
checkGroup.add(check2);
checkGroup.add(check3);
simple.add(checkGroup, formData);
Radio radio = new Radio();
radio.setBoxLabel("Red");
radio.setValue(true);
Radio radio2 = new Radio();
radio2.setBoxLabel("Blue");
RadioGroup radioGroup = new RadioGroup();
radioGroup.setFieldLabel("Favorite Color");
radioGroup.add(radio);
radioGroup.add(radio2);
simple.add(radioGroup, formData);
Radio radio3 = new Radio();
radio3.setBoxLabel("Apple");
radio3.setValue(true);
Radio radio4 = new Radio();
radio4.setBoxLabel("Banana");
RadioGroup radioGroup2 = new RadioGroup();
radioGroup2.setFieldLabel("Favorite Fruit");
radioGroup2.add(radio3);
radioGroup2.add(radio4);
simple.add(radioGroup2, formData);
TextArea description = new TextArea();
description.setPreventScrollbars(true);
description.setFieldLabel("Description");
simple.add(description, formData);
Button b = new Button("Submit");
simple.addButton(b);
simple.addButton(new Button("Cancel"));
simple.setButtonAlign(HorizontalAlignment.CENTER);
FormButtonBinding binding = new FormButtonBinding(simple);
binding.addButton(b);
SpinnerField spinnerField = new SpinnerField();
spinnerField.setIncrement(.1d);
spinnerField.getPropertyEditor().setType(Double.class);
spinnerField.getPropertyEditor().setFormat(NumberFormat.getFormat("00.0"));
spinnerField.setFieldLabel("Duration (s)");
spinnerField.setMinValue(-10d);
spinnerField.setMaxValue(10d);
simple.add(spinnerField, formData);
vp.add(simple);
}