3

I want to add a TextItem component into a HLayout in SmartGwt. I would just want to avoid adding each component to DynamicForm and then to a Layout Instead I want to directly add a TextItem to HLayout.

public class Test4 implements EntryPoint {
 DynamicForm dynamicForm = new DynamicForm();
 TextItem textItem = new TextItem();

HLayout hLayout = new HLayout();
    public void onModuleLoad() {
    //  dynamicForm.setFields(textItem);


        hLayout.addMember(textItem);
        hLayout.draw();
    }
}
aymeric
  • 3,877
  • 2
  • 28
  • 42

1 Answers1

4

HLayout.addMember() method accepts a Widget or Canvas as an argument. TextItem extends the FormItem which doesn't extent any of the above classes. Thus it is imposible to achieve what your code states. Your only solution is to add it through a DynamicForm using the setFields() method. If you have more than one TextItems you can just call something like the below:

dynamicForm.setFields(textItem1, textItem2, textItem3, ..., textItemN);

If you do not wish to be able to change the value of the textItem you can always use a Label or create a custom widget from simpler classes to achieve the look of the TextItem.

gpapaz
  • 889
  • 14
  • 23