将按钮元素换行到按钮



我正在尝试将ButtonElement包装到Button中:

@UiField ButtonElement myButton;
Button theButton = Button.wrap(myButton);

但是,我收到此错误:

@UiField myButton, template field and owner field types don't match: com.google.gwt.dom.client.ButtonElement is not assignable to com.google.gwt.user.client.ui.Button
这意味着

,虽然你的java代码中有ButtonElement,但名为"myButton"的uibinder标签实际上是一个Button小部件,而不是一个ButtonElement的elt。

将 uibinder 更改为实际使用 <button> ,或将@UiField更改为按钮(并放弃wrap(...)调用)。