首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UiBinder动态DockPanel

UiBinder动态DockPanel
EN

Stack Overflow用户
提问于 2010-03-23 13:10:30
回答 1查看 1.8K关注 0票数 1

很简单的问题...如果我在左边有一个StackLayoutPanel,我想在右边的我的DockLayoutPanel中点击一个动态加载的小部件...类似于GWt示例http://gwt.google.com/samples/Mail/Mail.html..点击邮箱下的任何东西都会在右边触发一个不同的窗口小部件...

EN

回答 1

Stack Overflow用户

发布于 2010-05-06 23:11:03

我没有使用您正在使用的特定小部件,但这是大体思路。

代码语言:javascript
复制
public class Index implements EntryPoint {

    public void onModuleLoad() {
        // the panel that holds the content widgets
        final SimplePanel mainPanel = new SimplePanel();
        // the panel that holds the links
        FlowPanel leftPanel = new FlowPanel();
        // the first content widget
        final Label oneContent = new Label("one content");
        // the second content widget
        final Label twoContent = new Label("two content");
        // the anchor to load the first content widget when clicked
        Anchor one = new Anchor("one menu");
        // add the click handler to do the content swap
        one.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                // remove any previous content
                mainPanel.clear();
                // add the first content widget
                mainPanel.add(oneContent);
            }
        });

        // the anchor to load the first content widget when clicked
        Anchor two = new Anchor("two menu");
        // add the click handler to do the content swap
        two.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                // remove any previous content
                mainPanel.clear();
                // add the second content widget
                mainPanel.add(twoContent);
            }
        });

        leftPanel.add(one);
        leftPanel.add(two);
        // add everything to the RootPanel
        RootPanel.get().add(leftPanel);
        RootPanel.get().add(mainPanel);
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2497719

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档