我正在尝试创建我自己的复合按钮,使用div作为外部父按钮:
public class CompoundButton extends ButtonBase {
public CompoundButton() {
super(DOM.createDiv());
}
}不过,ButtonBase的构造函数需要一个Element实例,所以我使用DOM.createDiv()调用。但是现在如何添加子小部件呢?:
public CompoundButton() {
super(DOM.createDiv()); <-- we're just a div.
// ButtonBase has no "add()" method - but this class is really
// just a div instance, so shouldn't I be able to convert it to
// a FlowPanel for example to be able to add elements to it here?
this.add(new FlowPanel()); <-- not possible, "add()" not available here.谢谢
发布于 2012-12-18 14:50:23
Button base接受一个单元格,而flowpanel不是一个单元格,您的复合按钮代码是错误的,因为它不会将单元格发送给它的父级。
正确的代码是
public class CompoundButton<C> extends ButtonBase<C>
{
protected CompoundButton( ButtonCellBase<C> cell )
{
super( cell );
}
}https://stackoverflow.com/questions/13922135
复制相似问题