【问题标题】:How to have fixed position panel in GWT?如何在 GWT 中有固定位置面板?
【发布时间】:2011-12-17 09:17:42
【问题描述】:

我有一个大的 SimpleLayoutPanel,它位于 RootLayoutPanel.get() 中,这是一个约束。

现在我想放置一些额外的面板并希望它具有位置:固定在浏览器屏幕中。有可能吗?

我既不能用 setStyleName()/CSS 也不能用 DOM.setStyleAttribute() 来设置这个样式。在这两种情况下,我的风格都被 GWT 所取代

谢谢

我成功的代码

我同时使用了两个根面板

public void onModuleLoad() {

    SimpleLayoutPanel simpleLayoutPanel = new SimpleLayoutPanel();
    simpleLayoutPanel.setStyleName("SimpleLayoutPanel");

    DOM.setStyleAttribute(simpleLayoutPanel.getElement(), "backgroundColor", "blue");

    RootLayoutPanel rootLayoutPanel = RootLayoutPanel.get();
    rootLayoutPanel.add(simpleLayoutPanel);

    LayoutPanel layoutPanel = new LayoutPanel();
    layoutPanel.setStyleName("LayoutPanel");
    DOM.setStyleAttribute(layoutPanel.getElement(), "position", "fixed");
    DOM.setStyleAttribute(layoutPanel.getElement(), "bottom", "0px");
    DOM.setStyleAttribute(layoutPanel.getElement(), "height", "100px");
    DOM.setStyleAttribute(layoutPanel.getElement(), "width", "100px");
    DOM.setStyleAttribute(layoutPanel.getElement(), "backgroundColor", "red");

    RootPanel rootPanel = RootPanel.get();
    rootPanel.add(layoutPanel);


}

【问题讨论】:

    标签: java gwt position panel fixed


    【解决方案1】:

    RootLayoutPanel 和 RootPanel 可以同时使用。

    我成功了。我需要接收调整大小事件的元素已放入 RootLayoutPanel。并且我需要固定定位的元素已放入 RootLayout。

    我发现没有办法将所有内容都放在一个根面板风格中。

    【讨论】:

      【解决方案2】:

      如果我理解正确,您应该能够使用父面板的 add(Widget/Panel, int x, int y) 方法来指定像素级别的确切位置。因此,如果您的 Root 面板名为 root,并且想在 100、100 处添加另一个面板 somePanel,那么 root.add(somePanel, 100, 100) 应该可以完成这项工作。

      【讨论】:

        猜你喜欢
        • 2012-03-14
        • 2014-10-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-28
        相关资源
        最近更新 更多