Search code examples
gwtgwt2

TabLayoutPanel not showing widgets only Tab items are visible


Simple example of TabLayoutPanel not showing container widgets only Tab items are visible. Something going wrong is it works for IE8

public class DemoGWT implements EntryPoint {
    RootPanel rp = RootPanel.get();

    public void onModuleLoad() {
        TabLayoutPanel panel = new TabLayoutPanel(25, Unit.PX);
        Label a = new Label("One Container");
        panel.add(a, "One Hdr");
        panel.add(new Label("Two Container"), "Two Hdr");
        panel.add(new Label("Three Container"), "Three Hdr");
        panel.add(new Label("Four Container"), "Four Hdr");
        panel.add(new Label("Five Container"), "Five Hdr");
        panel.add(new Label("Six Container"), "Six Hdr");

        rp.add(panel);
    }
}

Solution

  • Don't mix up Layout panels and panels. When you use layout panels such as TabLayoutPanel, Make sure its parent and their parent upto RootPanel are layout panels. Use RootLayoutPanel instead of RootPanel. TabLayoutPanel will not display data unless you mention its absolute height. (Note 100% or any other % won't work). It has to be absolute.

    Change the RootPanel to RootLayoutPanel and use setHeight(height) API of your TabLayoutPanel. Don't mention height in %age.