简体   繁体   English

GWT中如何有固定位置面板?

[英]How to have fixed position panel in GWT?

I have one big SimpleLayoutPanel which is located in RootLayoutPanel.get() and this is a constraint. 我有一个很大的SimpleLayoutPanel,它位于RootLayoutPanel.get()中,这是一个约束。

Now I want to place some extra panel and want it have position:fixed within browser screen. 现在,我想放置一些额外的面板,并希望它具有position:fixed在浏览器屏幕内。 Is it possible? 可能吗?

I can set this style neither with setStyleName()/CSS, nor with DOM.setStyleAttribute(). 我既不能使用setStyleName()/ CSS也不可以使用DOM.setStyleAttribute()来设置此样式。 In both cases my style is overrining by GWT's 在这两种情况下,我的风格都被GWT的

Thanks 谢谢

the code I succeeded 我成功的代码

I used both root panels simultaneously 我同时使用了两个根面板

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);


}

Both RootLayoutPanel and RootPanel can be used simultaneously. RootLayoutPanel和RootPanel可以同时使用。

I succeeded this way. 我这样成功了。 The elements I need to receive resize events, have been put into RootLayoutPanel. 我需要接收调整大小事件的元素已放入RootLayoutPanel中。 And the elements I need to have positioned with fixed, have been put into RootLayout. 我需要固定定位的元素已放入RootLayout。

I found no way to put everything into one root panel flavour. 我发现无法将所有内容都放在根面板中。

If I understood correctly you should be able to use the parent panel's add(Widget/Panel, int x, int y) method to specify exact location at pixel level. 如果我正确理解,则应该能够使用父面板的add(Widget / Panel,int x,int y)方法在像素级别指定确切位置。 So if you have your Root panel called root, and want to add another panel somePanel at 100, 100, root.add(somePanel, 100, 100) should do the job. 因此,如果您有一个名为root的Root面板,并且想在100、100处添加另一个面板somePanel,则root.add(somePanel,100、100)应该可以完成此工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM