Java 我可以在GWT2.0中混合使用声明式和编程式布局吗?
我正在尝试重做我在GWT2.0发布之前制作的现有面板。该面板有几个文本字段和下面垂直面板中的可滚动面板 我想做的是使用UIBinder制作可滚动面板,然后将其添加到垂直面板中。下面是我创建的一个示例,用于说明这一点:Java 我可以在GWT2.0中混合使用声明式和编程式布局吗?,java,gwt,layout,uibinder,Java,Gwt,Layout,Uibinder,我正在尝试重做我在GWT2.0发布之前制作的现有面板。该面板有几个文本字段和下面垂直面板中的可滚动面板 我想做的是使用UIBinder制作可滚动面板,然后将其添加到垂直面板中。下面是我创建的一个示例,用于说明这一点: public class ScrollTablePanel extends ResizeComposite{ interface Binder extends UiBinder<Widget, ScrollTablePanel > { } pri
public class ScrollTablePanel extends ResizeComposite{
interface Binder extends UiBinder<Widget, ScrollTablePanel > { }
private static Binder uiBinder = GWT.create(Binder.class);
@UiField FlexTable table1;
@UiField FlexTable table2;
public Test2() {
initWidget(uiBinder.createAndBindUi(this));
table1.setText(0, 0, "testing 1");
table1.setText(0, 1, "testing 2");
table1.setText(0, 2, "testing 3");
table2.setText(0, 0, "testing 1");
table2.setText(0, 1, "testing 2");
table2.setText(0, 2, "testing 3");
table2.setText(1, 0, "testing 4");
table2.setText(1, 1, "testing 5");
table2.setText(1, 2, "testing 6");
}
}
但是当我将ScrollTablePanel添加到VerticalPanel时,页面上只有第一个FlexTable(test1)可见,而不是整个ScrollTablePanel
在GWT2.0中可以混合声明式和编程式布局的情况下,有没有一种方法可以实现这一点?您当然可以,尽管它有点超出了使用uiBinder的初衷。当然,当您必须使用动态gui元素(如FlexTable)时,您不能避免初始化代码,但仍然可以使用@UiFactory和@UiField(提供=true)来避免其中的一些。 我相信您的问题与容器垂直面板的大小有关,请尝试将其设置为100%
<ui:UiBinder
xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
xmlns:mail='urn:import:com.test.scrollpaneltest'>
<g:DockLayoutPanel unit='EM'>
<g:north size="2">
<g:FlexTable ui:field="table1"></g:FlexTable>
</g:north>
<g:center>
<g:ScrollPanel>
<g:FlexTable ui:field="table2"></g:FlexTable>
</g:ScrollPanel>
</g:center>
</g:DockLayoutPanel>
</ui:UiBinder>
public void onModuleLoad() {
VerticalPanel vp = new VerticalPanel();
vp.add(new ScrollTablePanel());
vp.add(new Label("dummy label text"));
vp.setWidth("100%");
RootLayoutPanel.get().add(vp);
}