Search code examples
javagwtpositionpanelfixed

How to have fixed position panel in GWT?


I have one big SimpleLayoutPanel which is located in RootLayoutPanel.get() and this is a constraint.

Now I want to place some extra panel and want it have position:fixed within browser screen. Is it possible?

I can set this style neither with setStyleName()/CSS, nor with DOM.setStyleAttribute(). In both cases my style is overrining by GWT's

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


}

Solution

  • Both RootLayoutPanel and RootPanel can be used simultaneously.

    I succeeded this way. The elements I need to receive resize events, have been put into RootLayoutPanel. And the elements I need to have positioned with fixed, have been put into RootLayout.

    I found no way to put everything into one root panel flavour.