如何在 Smartgwt 2.4 中将 TextItem 添加到 HLayout?

发布于 2025-01-03 06:50:02 字数 528 浏览 2 评论 0原文

我想将 TextItem 组件添加到 SmartGwt 中的 HLayout 中。 我只是想避免将每个组件添加到DynamicForm,然后添加到Layout 相反,我想直接将 TextItem 添加到 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();
    }
}

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();
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不咬妳我踢妳 2025-01-10 06:50:02

HLayout.addMember() 方法接受 Widget 或 Canvas 作为参数。 TextItem 扩展了 FormItem,但不扩展上述任何类。因此不可能实现您的代码所述的内容。您唯一的解决方案是使用 setFields() 方法通过 DynamicForm 添加它。如果您有多个 TextItem,您可以调用如下所示的内容:

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

如果您不希望能够更改 textItem 的值,您始终可以使用 Label 或从更简单的类创建自定义小部件以实现以下外观:文本项。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文