2013-08-22 58 views
0

GXT对齐图像我有我需要用一个组合框与组合框

<container:VerticalLayoutContainer addStyleNames="{mystyle}"> 
    <form:FieldLabel text="{constants.typ}" labelAlign="TOP"> 
     <form:widget> 
      <form:ComboBox ui:field="type" width="300" allowBlank="true" forceSelection="true" triggerAction="ALL" /> 
     </form:widget> 
    </form:FieldLabel> 
    <g:Image resource="{loadingGif}" ui:field="Monimage" /> 
</container:VerticalLayoutContainer> 

在我看来对齐loading.gif形象,我为我的DATAS一个liststore。 我试图把我的图像放在<form:widget>里面,但是它开始一个例外,说我只能为每个ui:child创建一个元素。

使用此代码,我的图像位于组合框下,我需要它位于右侧。 任何人都可以帮助我吗?

回答

1

当uiBinder解析器看到<form:widget>时,它会尝试调用方法FieldLabel#setWidget(theComponentUnderTheTag)

这就是为什么在<form:widget>标记下有多个元素没有意义。

当我不能做我想要的GWT时,我回退到一些普通的旧HTML。随着UiBinder的,你可以用HTMLPanel实现这一目标:

<container:VerticalLayoutContainer addStyleNames="{mystyle}"> 
    <form:FieldLabel text="{constants.typ}" labelAlign="TOP"> 
    <form:widget> 

     <g:HTMLPanel> 
     <!-- 
     Here, I can now place plain old HTML :) 
     Let's place the 2 components via 2 divs and a float:left. 
     --> 
     <div style="float:left"> 
      <form:ComboBox ui:field="type" width="300" allowBlank="true" forceSelection="true" triggerAction="ALL" /> 
     </div> 
     <div> 
      <g:Image resource="{loadingGif}" ui:field="Monimage" />           
     </div> 
     </g:HTMLPanel> 

    </form:widget> 
    </form:FieldLabel> 
</container:VerticalLayoutContainer> 

如果你不想使用HTML面板,你可以把两个元素在<form:widget>标签。

但是为了实现这一点,您需要将它们包装在一个组件中(例如,HorizontalPanel),因为您只能在<form:widget>下放置一个窗口小部件。

<form:FieldLabel text="{constants.typ}" labelAlign="TOP"> 
    <form:widget> 
     <g:HorizontalPanel> 
      <g:ComboBox ui:field="type" width="300" allowBlank="true" forceSelection="true" triggerAction="ALL" /> 
      <g:Image resource="{loadingGif}" ui:field="Monimage" /> 
     </g:HorizontalPanel> 
    </form:widget> 
</form:FieldLabel> 
+0

你写的一切都很好,谢谢。我已经尝试了两种,我更喜欢HTML面板,因为我可以对我的元素有更多的控制权。 –