PDA

View Full Version : TextField in FieldSet



listirer
9 Dec 2011, 6:51 AM
How can I display the label of a TextField added into FieldSet?

Example code:


TextField<String> nameField = new TextField<String>();
nameField.setName("name");
nameField.setFieldLabel("Name");
nameField.setValue(user.getName());

FieldSet userFieldSet = new FieldSet();
userFieldSet.setHeading("User");
userFieldSet.setSize(400, 100);
userFieldSet.add(nameField);

FormPanel form = new FormPanel();
form.setHeaderVisible(false);
form.setBorders(false);
form.add(userFieldSet);


Thanks

cimballi
9 Dec 2011, 7:55 AM
If you look at the Explorer Demo you will see that you have to set the layout of the field set :

FormLayout layout = new FormLayout();
layout.setLabelWidth(75);
fieldSet.setLayout(layout);

listirer
9 Dec 2011, 8:05 AM
It works!

Thanks from a damned newbie...