我将“topPanel”UiField更改为引用FlowPanel而不是SimplePanel。
- 但是,当我这样做时,我的“视图”类中的原始“setWidget”方法不再有效。
我可以做什么调整( - 如果可以的话)允许FlowPanel“@UiField”正确编译和处理?
这是“视图”类...
public class TopPanel extends Composite implements AcceptsOneWidget
{
-
-
-
//...prev...@UiField
//...prev...SimplePanel topPanel;
//...Trying to make this work...
@UiField
FlowPanel topPanel;
-
-
-
//...how should this method be modified or replaced to allow the FlowPanel "@UiField" to work?....
@Override
public void setWidget(IsWidget w)
{
topPanel.setWidget(w);
}
}
这是uiBinder模板......
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:style src="app.css" />
<g:HTMLPanel width="50%" height="50%">
<!-- <g:SimplePanel ui:field="topPanel"> -->
<g:FlowPanel ui:field="topPanel">
<g:Button text="from aaa: go to bbb" ui:field="topButtonA"></g:Button>
<g:Button text="from bbb: go to ccc" ui:field="topButtonB"></g:Button>
<g:Button text="from ccc: go to aaa" ui:field="topButtonC"></g:Button>
</g:FlowPanel>
</g:HTMLPanel>
</ui:UiBinder>
答案 0 :(得分:0)
尝试:
topPanel.insert(w,0)
而不是
topPanel.setWidget(w)
答案 1 :(得分:0)
如果要在topPanel中包含的按钮下方/之后添加小部件,则应使用:
topPanel.add(w)