Search code examples
gwtgxt

[GWT]why I can't find the widget that has been added to the css layout container?


import com.sencha.gxt.widget.core.client.container.CssFloatLayoutContainer;

public class myApp{
  private CssFloatLayoutContainer a;
  private CssFloatLayoutContainer b;

  private Image aButton;
  private Image bButton;

  private IsWidget getIcons() {
        a= new CssFloatLayoutContainer();
        a.setStyleFloat(Float.RIGHT);
        b= new CssFloatLayoutContainer();
        b.setStyleFloat(Float.RIGHT);

        // Icon a
        a.add(aButton);

        // Icon b
        a.add(bButton);
        b.add(bButtion);

        if (true) {
            a.hide();
            return b;
        } else {
            return a;
        }
   }

}

I can't find bButton in my page, then I checked the source code and I find it just has aButton. Anyone who can tell me why this situation can happens?


Solution

  • The same widget cannot belong to two different parent widgets.

    You either have to create another copy of your bButton, or you need to add it to a new parent each time you switch containers in your if method.