Package com.google.gwt.user.client.ui
Class LazyPanel
java.lang.Object
com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.Panel
com.google.gwt.user.client.ui.SimplePanel
com.google.gwt.user.client.ui.LazyPanel
- All Implemented Interfaces:
HasAttachHandlers,HasHandlers,EventListener,AcceptsOneWidget,HasOneWidget,HasVisibility,HasWidgets,HasWidgets.ForIsWidget,IsWidget,Iterable<Widget>
Convenience class to help lazy loading. The bulk of a LazyPanel is not
instantiated until
setVisible(boolean)(true) or ensureWidget() is
called.
Example
public class LazyPanelExample implements EntryPoint {
private static class HelloLazyPanel extends LazyPanel {
@Override
protected Widget createWidget() {
return new Label("Well hello there!");
}
}
public void onModuleLoad() {
final Widget lazy = new HelloLazyPanel();
// Not strictly necessary, but keeps the empty outer div
// from effecting layout before it is of any use
lazy.setVisible(false);
PushButton b = new PushButton("Click me");
b.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
lazy.setVisible(true);
}
});
RootPanel root = RootPanel.get();
root.add(b);
root.add(lazy);
}
}
-
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.ForIsWidget -
Field Summary
Fields inherited from class com.google.gwt.user.client.ui.SimplePanel
widgetFields 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract WidgetCreate the widget contained within theLazyPanel.voidEnsures that the widget has been created by callingcreateWidget()ifSimplePanel.getWidget()returnsnull.voidsetVisible(boolean visible) Sets whether this object is visible.Methods inherited from class com.google.gwt.user.client.ui.SimplePanel
add, getContainerElement, getWidget, iterator, remove, setWidget, setWidgetMethods 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, setWidth, sinkBitlessEvent, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
LazyPanel
public LazyPanel()
-
-
Method Details
-
createWidget
Create the widget contained within theLazyPanel.- Returns:
- the lazy widget
-
ensureWidget
public void ensureWidget()Ensures that the widget has been created by callingcreateWidget()ifSimplePanel.getWidget()returnsnull. Typically it is not necessary to call this directly, as it is called as a side effect of asetVisible(true)call. -
setVisible
public void setVisible(boolean visible) Description copied from interface:HasVisibilitySets whether this object is visible.- Specified by:
setVisiblein interfaceHasVisibility- Overrides:
setVisiblein classUIObject- Parameters:
visible-trueto show the object,falseto hide it
-