sz_146
2 Apr 2009, 3:38 AM
I have the following form which displays Address fields. I have 2 issues :
The labels and fields are not align i.e. the Labels appear slightly above the fields which look awkward
I can't set the field width on particular fields e.g. Postcode and County. I have tried all sorts of setWidth setSize etc.
protected ContentPanel getAddressPanel(){
ContentPanel addressData = new ContentPanel();
FormLayout fl = new FormLayout();
fl.setLabelAlign(LabelAlign.RIGHT);
addressData.setLayout(fl);
addressData.setCollapsible(true);
addressData.setHeading("Address " + (getAddressCount() + 1) );
String[] labels = {"Line 1", "Line 2", "Line 3", "Town/City", "County", "Postcode"};
renderAddressFields(labels, addressData);
return addressData;
}
private void renderAddressFields(String[] labels, LayoutContainer cont){
for(String s : labels){
TextField<String> txtField = new TextField<String>();
txtField.setFieldLabel(s);
// Need the field width to be 8 chars setWidth and setSize doesn't work
if(s.equals("Postcode")){
txtField.setMaxLength(8);
}
cont.add(txtField);
addressFieldsHash.put(getNextAddressFieldID(), txtField);
}
}
The labels and fields are not align i.e. the Labels appear slightly above the fields which look awkward
I can't set the field width on particular fields e.g. Postcode and County. I have tried all sorts of setWidth setSize etc.
protected ContentPanel getAddressPanel(){
ContentPanel addressData = new ContentPanel();
FormLayout fl = new FormLayout();
fl.setLabelAlign(LabelAlign.RIGHT);
addressData.setLayout(fl);
addressData.setCollapsible(true);
addressData.setHeading("Address " + (getAddressCount() + 1) );
String[] labels = {"Line 1", "Line 2", "Line 3", "Town/City", "County", "Postcode"};
renderAddressFields(labels, addressData);
return addressData;
}
private void renderAddressFields(String[] labels, LayoutContainer cont){
for(String s : labels){
TextField<String> txtField = new TextField<String>();
txtField.setFieldLabel(s);
// Need the field width to be 8 chars setWidth and setSize doesn't work
if(s.equals("Postcode")){
txtField.setMaxLength(8);
}
cont.add(txtField);
addressFieldsHash.put(getNextAddressFieldID(), txtField);
}
}