0

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.

ありがとう

4

1 に答える 1

0

ボタンベースはセルを取得しますが、flowpanelはセルではなく、複合ボタンのコードはセルを親に送信しないため間違っています。

適切なコードは

public class CompoundButton<C> extends ButtonBase<C>
{
   protected CompoundButton( ButtonCellBase<C> cell )
   {
        super( cell );
   }
}
于 2012-12-18T06:50:23.430 に答える