Custom gxt Cell which may take Widget(自定义 gxt Cell 可能需要 Widget)
问题描述
我需要一个可以在其中放置小部件的列.我有这个:
I need a Column in which it was possible to put a Widget. I have this:
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.ui.Widget;
public class WidgetGridCell extends AbstractCell<Widget> {
Widget widget;
public WidgetGridCell(Widget widget) {
this.widget = widget;
}
@Override
public void render(Context paramContext,
Widget param, SafeHtmlBuilder pb) {
}
}
但我不知道如何在 HTML 中包含小部件
But I do not know how to include the widget in HTML
附:或者不是 Widget,只有 GWT Button 适合我.
P.S. Or not Widget, only GWT Button will suit me.
推荐答案
参见这里 了解 AbstractCell 实现的一些示例.
See here for a number of examples of AbstractCell implementations.
要回答有关 GWT 按钮的问题:
To answer your question regarding a GWT button:
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.ui.Widget;
public class WidgetGridCell extends AbstractCell<Widget> {
Widget widget;
public WidgetGridCell(Widget widget) {
this.widget = widget;
}
@Override
public void render(Context paramContext,
Widget param, SafeHtmlBuilder pb) {
Button aButton = new Button();
// add text to the button, etc...
pb.append(SafeHtmlUtils.fromTrustedString(aButton.toString()));
}
}
尝试在单元格元素中渲染整个小部件在很大程度上是不可行的(也不可取),但听起来好像您真的在尝试从单元格中渲染按钮.
It's largely not feasible (and not advisable) to try and render an entire widget within a cell element but it sounds as though you are really trying to render a button from within the cell.
AbstractCell 是 Cell 接口的一个实现,它允许您定义要在单元格中呈现的 HTML.如果您需要一个可以响应事件的按钮,则需要定义自定义单元格来处理浏览器事件(例如单击事件).Google 在其关于自定义单元格的文档中做得很好,解释了如何去做.
AbstractCell is an implementation of the Cell interface which allows you to define the HTML to render within the cell. If you need a button which can respond to events you'll need to define your custom cell to handle browser events (such as the click event). Google does a good job in their documentation on custom cells explaining how you can go about doing that.
查看此链接:http://www.gwtproject.org/doc/latest/DevGuideUiCustomCells.html
这篇关于自定义 gxt Cell 可能需要 Widget的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:自定义 gxt Cell 可能需要 Widget
基础教程推荐
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 降序排序:Java Map 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01