Is there a `AcceptsOneWidget` which also `ProvidesResze` (other than `ScrollPanel`)?

只谈情不闲聊 提交于 2019-12-06 02:29:51

You can add ProvidesResize to any widget by implementing it yourself, which is relatively simple - you just pass along all of the resize notifications you get to every sub-child that RequiresResize.

Alternatively, if you just want your panel to take up all of the available space, you might try setting the width and height on the ScrollPanel to "100%".

Finally, here's my implementation of a LayoutPanel that AcceptsOneWidget:

public class PanelForView extends LayoutPanel implements AcceptsOneWidget
{
    IsWidget myWidget = null;

    @Override
    public void setWidget(IsWidget w)
    {
        if (myWidget != w)
        {
            if (myWidget != null)
            {
                remove(myWidget);
            }

            if (w != null)
            {
                add(w);
            }

            myWidget = w;
        }
    }

}

I've been using this in my commercial app for months without any problems, and it's easy to swap views in and out of it. Feel free to use this code yourself.

There will be a SimpleLayoutPanel in GWT 2.3, described as:

A simple panel that {@link ProvidesResize} to its one child.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!