Class RootPanel
- All Implemented Interfaces:
HasAttachHandlers,HasHandlers,EventListener,HasVisibility,HasWidgets,HasWidgets.ForIsWidget,IndexedPanel,IndexedPanel.ForIsWidget,InsertPanel,InsertPanel.ForIsWidget,IsWidget,Iterable<Widget>
get()
.
Most applications will add widgets to the default root panel in their
EntryPoint.onModuleLoad() methods.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabledNested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasWidgets
HasWidgets.ForIsWidgetNested classes/interfaces inherited from interface com.google.gwt.user.client.ui.IndexedPanel
IndexedPanel.ForIsWidgetNested classes/interfaces inherited from interface com.google.gwt.user.client.ui.InsertPanel
InsertPanel.ForIsWidget -
Field Summary
Fields inherited from class com.google.gwt.user.client.ui.Widget
eventsToSinkFields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX, MISSING_ELEMENT_ERROR, SETELEMENT_TWICE_ERROR -
Method Summary
Modifier and TypeMethodDescriptionvoidclear(boolean clearDom) Deprecated.Simply removing all DOM elements can cause issues with other elements in the page.static voidDeprecated.Instead, useWidget.removeFromParent().static voiddetachOnWindowClose(Widget widget) Deprecated.While originally introduced to combat memory leaks in old browsers, this is no longer necessary, and the unload event used by this method is being removed from browsers.static voidDeprecated.See notice ondetachOnWindowClose(Widget)and Issue 9908 for more information.static RootPanelget()Gets the default root panel.static RootPanelGets the root panel associated with a given browser element.static ElementConvenience method for getting the document's body element.static booleanisInDetachList(Widget widget) Deprecated.Use of the detach list requires the unload event, which is planned to be removed in future browser updates.Methods inherited from class com.google.gwt.user.client.ui.AbsolutePanel
add, add, add, getWidgetLeft, getWidgetTop, insert, insert, insert, remove, setWidgetPosition, setWidgetPositionImplMethods inherited from class com.google.gwt.user.client.ui.ComplexPanel
add, add, adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, doLogicalClear, getChildren, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, insert, insert, iterator, removeMethods inherited from class com.google.gwt.user.client.ui.Panel
add, adopt, clear, doAttachChildren, doDetachChildren, orphan, removeMethods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, ensureHandlers, fireEvent, getHandlerCount, getHandlerManager, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, replaceElement, setLayoutData, setParent, sinkEvents, unsinkEventsMethods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.google.gwt.user.client.ui.IndexedPanel
getWidget, getWidgetCount, getWidgetIndex, removeMethods inherited from interface com.google.gwt.user.client.ui.IndexedPanel.ForIsWidget
getWidgetIndexMethods inherited from interface com.google.gwt.user.client.ui.InsertPanel.ForIsWidget
addMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
detachNow
Deprecated.Instead, useWidget.removeFromParent().Marks a widget as detached and removes it from the detach list.If an element belonging to a widget originally passed to
detachOnWindowClose(Widget)has been removed from the document, calling this method will cause it to be marked as detached immediately. Failure to do so will keep the widget from being garbage collected until the page is unloaded.This method may only be called per widget, and only for widgets that were originally passed to
detachOnWindowClose(Widget).- Parameters:
widget- the widget that no longer needs to be cleaned up when the page closes- See Also:
-
detachOnWindowClose
Deprecated.While originally introduced to combat memory leaks in old browsers, this is no longer necessary, and the unload event used by this method is being removed from browsers. Additionally, it is unreliable as a means to ensure calls toWidget.onUnload(). See Issue 9908 for more information.Adds a widget to the detach list. This is the list of widgets to be detached when the page unloads.This method must be called for all widgets that have no parent widgets. These are most commonly
RootPanels, but can also be any widget used to wrap an existing element on the page. Failing to do this may cause these widgets to leak memory. This method is called automatically by widgets' wrap methods (e.g.Button.wrap(Element)).This method may not be called on any widget whose element is contained in another widget. This is to ensure that the DOM and Widget hierarchies cannot get into an inconsistent state.
- Parameters:
widget- the widget to be cleaned up when the page closes- See Also:
-
get
Gets the default root panel. This panel wraps the body of the browser's document. This root panel can contain any number of widgets, which will be laid out in their natural HTML ordering. Many applications, however, will add a single panel to the RootPanel to provide more structure.- Returns:
- the default RootPanel
-
get
Gets the root panel associated with a given browser element. For this to work, the HTML document into which the application is loaded must have specified an element with the given id.- Parameters:
id- the id of the element to be wrapped with a root panel (nullspecifies the default instance, which wraps the <body> element)- Returns:
- the root panel, or
nullif no such element was found
-
getBodyElement
Convenience method for getting the document's body element.- Returns:
- the document's body element
-
isInDetachList
Deprecated.Use of the detach list requires the unload event, which is planned to be removed in future browser updates. See notice ondetachOnWindowClose(Widget)and Issue 9908 for more information.Determines whether the given widget is in the detach list.Note that modern browsers do not have the memory leaks that originally required use of this feature - it is retained only to support application-specific detach events.
- Parameters:
widget- the widget to be checked- Returns:
trueif the widget is in the detach list
-
detachWidgets
Deprecated.See notice ondetachOnWindowClose(Widget)and Issue 9908 for more information.Detaches all widgets that were set to be detached on window close by a call todetachOnWindowClose(com.google.gwt.user.client.ui.Widget). Formerly was package-protected, now can be called by projects that required the old behavior and are willing to set up their own onclose handler on the window.Note that modern browsers do not have the memory leaks that originally required use of this feature - it is retained only to support application-specific detach events.
-
clear
Deprecated.Simply removing all DOM elements can cause issues with other elements in the page.Clears the rootPanel. If clearDom is true, then also remove any DOM elements that are not widgets.By default
Panel.clear()will only remove children that are GWT widgets. This method also provides the option to remove all children including the non-widget DOM elements that are directly added (e.g. elements added viagetElement().appendChild(...).- Parameters:
clearDom- iftruethis method will also remove any DOM elements that are not widgets.
-