PDA

View Full Version : [CLOSED] Setting fieldWidth in FormPanel



ashleywong
2 Jun 2008, 8:13 PM
Is it possible to customize the components width?

In FormPanelPages sample, even I've commented panel.setFieldWidth(210) and panel.setLabelWidth(100), the width of combo box cannot be altered.


public class FormPanelPage extends LayoutContainer implements EntryPoint {

public void onModuleLoad() {
RootPanel.get().add(this);
}

@Override
protected void onRender(Element parent, int pos) {
super.onRender(parent, pos);

FormPanel panel = new FormPanel();
panel.setFrame(true);
panel.setButtonAlign(HorizontalAlignment.CENTER);
panel.setHeading("Simplea Form");
panel.setIconStyle("icon-form");
panel.setWidth(600);
panel.setStyleAttribute("padding", "20");

TextField text = new TextField();
text.setFieldLabel("Name");
text.setEmptyText("Enter your full name");
text.setAllowBlank(false);
text.setMinLength(4);
panel.add(text);

NumberField number = new NumberField();
number.setFieldLabel("Age");
number.setEmptyText("Enter your age");
number.setAllowBlank(false);
panel.add(number);

text = new TextField();
text.setFieldLabel("Email");
panel.add(text);

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 store = new ListStore();
store.add(stocks);

ComboBox combo = new ComboBox();
combo.setFieldLabel("Company");
combo.setDisplayField("name");
combo.setWidth(400);
combo.setStore(store);
panel.add(combo);

DateField date = new DateField();
date.setFieldLabel("Birthday");
date.setWidth(210);
panel.add(date);

TimeField time = new TimeField();
time.setFieldLabel("Time");
time.setWidth(200);
panel.add(time);

CheckBox check1 = new CheckBox();
check1.setBoxLabel("Classical");

CheckBox check2 = new CheckBox();
check2.setBoxLabel("Rock");
check2.setValue(true);

CheckBox check3 = new CheckBox();
check3.setFieldLabel("Blue");

CheckBoxGroup checkGroup = new CheckBoxGroup();
checkGroup.setFieldLabel("Music");
checkGroup.add(check1);
checkGroup.add(check2);
checkGroup.add(check3);
panel.add(checkGroup);

Radio radio = new Radio();
radio.setName("radio");
radio.setFieldLabel("Red");
radio.setValue(true);

Radio radio2 = new Radio();
radio2.setName("radio");
radio2.setFieldLabel("Blue");

RadioGroup radioGroup = new RadioGroup("test");
radioGroup.setFieldLabel("Favorite Color");
radioGroup.add(radio);
radioGroup.add(radio2);
panel.add(radioGroup);

TextArea description = new TextArea();
description.setPreventScrollbars(true);
description.setInitialHeight(50);
description.setFieldLabel("Description");
panel.add(description);

panel.addButton(new Button("Save"));
panel.addButton(new Button("Cancel"));

add(panel);
}

}

ashleywong
2 Jun 2008, 8:18 PM
sorry for posting in wrong group

ashleywong
10 Jun 2008, 7:17 PM
anyone can help?

ashleywong
29 Jun 2008, 6:36 PM
I think using FormPanel, the individual field width cannot be altered. All fields will use the master field width (defined by FormPanel).

To customize the components width, we should use contentpanel to do so.