PDA

View Full Version : GXT widget and label resize.



mahendramohan
11 Oct 2011, 5:15 AM
Hi,
Will some one guide me how to resize/control the width of label-text.
For eg: you can resize the textfield widget by giving anchordata as the layout data. But if a considerably bigger string comes as the label, one cannot control its size atleast to the required length. It can be constrained to a specific length but the whole panel will not be under control. Some one in the above forum stated controlling using the formlayout, but it is not working in my case. The code I implemented is as shown below.



FormPanel formPanel = new FormPanel();
formPanel.setBorders(false);
formPanel.setBodyBorder(false);
formPanel.setFrame(true);
formPanel.setPadding(5);
formPanel.setHeaderVisible(false);

setLayout(new AnchorLayout());
setHeaderVisible(false);
textField_ = new TextField<String>();
textField_.setAutoWidth(true);
textField_.setAllowBlank(false);
textField_.setFieldLabel(fieldLabel);
formPanel.add(textField_, new FormData("100%"));

textField1_ = new TextField<String>();
textField1_.setAutoWidth(true);
textField1_.setAllowBlank(false);

String s = StringUtils.left("name2isconsiderablybigger", 5);
System.out.println("string :- " + s);

textField1_.setFieldLabel(s);
formPanel.add(textField1_, new FormData("100%"));
add(formPanel, new AnchorData("100%"));