gwtgwt-tablayoutpanel

How to add a scrollbar to an absolutepanel in GWT


my problem is that I have a lot of AbsolutePanels in GWT an they are drawn as if they were a TabLayoutPanel ( the GUI looks like a TabLayoutPanel, however, it is not one, it is made of a lot of AbsolutePanels ). So, now I have the problem that as soon as a lot of tabs are opened they exceed the max. width of the AbsolutePanel and so they cannot be seen anymore nor can they be clicked or anything else. So, is it somehow possible to add a ScrollBar to this AbsolutePanel in order to scroll back and forth?

I do not think it is a good idea to post any code because everything is being done programmatically. The only thing that I would need is an example of how to accomplish a scrollbar within an AbsolutePanel. This AbsolutePanel is of a fixed width!

Thank you very much for your help in advance.


Solution

  • Use CSS Overflow property.

    You just need to set overflow: auto;.

    It can be done programmatically:

    panel.getElement().getStyle().setOverflow(Overflow.AUTO);
    

    or with CSS style sheet:

    .overflowAuto {
        overflow: auto;
    }
    

    and

    panel.addStyleName("overflowAuto");