Class RootLayoutPanel

  • All Implemented Interfaces:
    HasAttachHandlers, HasHandlers, EventListener, AnimatedLayout, HasVisibility, HasWidgets, HasWidgets.ForIsWidget, IndexedPanel, IndexedPanel.ForIsWidget, IsWidget, ProvidesResize, RequiresResize, java.lang.Iterable<Widget>

    public class RootLayoutPanel
    extends LayoutPanel
    A singleton implementation of LayoutPanel that always attaches itself to the document body (i.e. RootPanel.get()).

    This panel automatically calls RequiresResize.onResize() on itself when initially created, and whenever the window is resized.

    NOTE: This widget will only work in standards mode, which requires that the HTML page in which it is run have an explicit <!DOCTYPE> declaration.

    Example

    public class LayoutPanelExample implements EntryPoint {
    
      public void onModuleLoad() {
        // Attach two child widgets to a LayoutPanel, laying them out horizontally,
        // splitting at 50%.
        Widget childOne = new HTML("left"), childTwo = new HTML("right");
        LayoutPanel p = new LayoutPanel();
        p.add(childOne);
        p.add(childTwo);
    
        p.setWidgetLeftWidth(childOne, 0, PCT, 50, PCT);
        p.setWidgetRightWidth(childTwo, 0, PCT, 50, PCT);
    
        // Attach the LayoutPanel to the RootLayoutPanel. The latter will listen for
        // resize events on the window to ensure that its children are informed of
        // possible size changes.
        RootLayoutPanel rp = RootLayoutPanel.get();
        rp.add(p);
      }
    }
    

    • Method Detail

      • get

        public static RootLayoutPanel get()
        Gets the singleton instance of RootLayoutPanel. This instance will always be attached to the document body via RootPanel.get().

        Note that, unlike RootPanel.get(String), this class provides no way to get an instance for any element on the page other than the document body. This is because we know of no way to get resize events for anything but the window.

      • onLoad

        protected void onLoad()
        Description copied from class: Widget
        This method is called immediately after a widget becomes attached to the browser's document.
        Overrides:
        onLoad in class Widget