Class CustomScrollPanel
- 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.ScrollPanel
-
- com.google.gwt.user.client.ui.CustomScrollPanel
-
- All Implemented Interfaces:
HasScrollHandlers,HasAttachHandlers,HasHandlers,EventListener,AcceptsOneWidget,HasHorizontalScrolling,HasOneWidget,HasScrolling,HasVerticalScrolling,HasVisibility,HasWidgets,HasWidgets.ForIsWidget,IsWidget,ProvidesResize,RequiresResize,SourcesScrollEvents,java.lang.Iterable<Widget>
public class CustomScrollPanel extends ScrollPanel
A custom version of theScrollPanelthat allows user provided scrollbars.The postion of scrollbars in a
CustomScrollPaneldiffers from that of a native scrollable element. In a native element, scrollbars appear adjacent to the content, shrinking the content client height and width when they appear.CustomScrollPanelinstead overlays scrollbars on top of the content, so the content does not change size when scrollbars appear. If the scrollbars obscures the content, you can set thepadding-topandpadding-bottomof the content to shift the content out from under the scrollbars.NOTE: Unlike
ScrollPanel, which implementsRequiresResizebut doesn't really require it,CustomScrollPanelactually does require resize and should only be added to a panel that implementsProvidesResize, such as most layout panels andResizeLayoutPanel.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCustomScrollPanel.ResourcesA ClientBundle of resources used by this widget.static interfaceCustomScrollPanel.StyleStyles used by this widget.-
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
-
Nested 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
widget
-
Fields inherited from class com.google.gwt.user.client.ui.Widget
eventsToSink
-
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX, MISSING_ELEMENT_ERROR, SETELEMENT_TWICE_ERROR
-
-
Constructor Summary
Constructors Constructor Description CustomScrollPanel()Creates an emptyCustomScrollPanel.CustomScrollPanel(CustomScrollPanel.Resources resources)CustomScrollPanel(Widget child)Creates aCustomScrollPanelwith the specified child widget.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoAttachChildren()If a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and callWidget.onAttach()for each of its child widgets.protected voiddoDetachChildren()If a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and callWidget.onDetach()for each of its child widgets.HorizontalScrollbargetHorizontalScrollbar()Get the scrollbar used for horizontal scrolling.VerticalScrollbargetVerticalScrollbar()Get the scrollbar used for vertical scrolling.protected voidonAttach()This method is called when a widget is attached to the browser's document.voidonBrowserEvent(Event event)Fired whenever a browser event is received.protected voidonDetach()This method is called when a widget is detached from the browser's document.protected voidonLoad()This method is called immediately after a widget becomes attached to the browser's document.voidonResize()This method must be called whenever the implementor's size has been modified.booleanremove(Widget w)Removes a child widget.voidremoveHorizontalScrollbar()Remove theHorizontalScrollbar, if one exists.voidremoveVerticalScrollbar()Remove theVerticalScrollbar, if one exists.voidsetAlwaysShowScrollBars(boolean alwaysShow)Sets whether this panel always shows its scroll bars, or only when necessary.voidsetHorizontalScrollbar(HorizontalScrollbar scrollbar, int height)Set the scrollbar used for horizontal scrolling.voidsetVerticalScrollbar(VerticalScrollbar scrollbar, int width)Set the scrollbar used for vertical scrolling.voidsetWidget(Widget w)Sets this panel's widget.-
Methods inherited from class com.google.gwt.user.client.ui.ScrollPanel
addScrollHandler, addScrollListener, ensureVisible, getContainerElement, getHorizontalScrollPosition, getMaximumHorizontalScrollPosition, getMaximumVerticalScrollPosition, getMinimumHorizontalScrollPosition, getMinimumVerticalScrollPosition, getScrollableElement, getScrollPosition, getVerticalScrollPosition, isTouchScrollingDisabled, removeScrollListener, scrollToBottom, scrollToLeft, scrollToRight, scrollToTop, setHeight, setHorizontalScrollPosition, setScrollPosition, setSize, setTouchScrollingDisabled, setVerticalScrollPosition, setWidth
-
Methods inherited from class com.google.gwt.user.client.ui.SimplePanel
add, getWidget, iterator, setWidget
-
Methods 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, onUnload, removeFromParent, replaceElement, setLayoutData, setParent, sinkEvents, unsinkEvents
-
Methods 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, setPixelSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, sinkBitlessEvent, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
-
-
-
-
Constructor Detail
-
CustomScrollPanel
public CustomScrollPanel()
Creates an emptyCustomScrollPanel.
-
CustomScrollPanel
public CustomScrollPanel(CustomScrollPanel.Resources resources)
-
CustomScrollPanel
public CustomScrollPanel(Widget child)
Creates aCustomScrollPanelwith the specified child widget.- Parameters:
child- the widget to be wrapped by the scroll panel
-
-
Method Detail
-
getHorizontalScrollbar
public HorizontalScrollbar getHorizontalScrollbar()
Get the scrollbar used for horizontal scrolling.- Returns:
- the horizontal scrollbar, or null if none specified
-
getVerticalScrollbar
public VerticalScrollbar getVerticalScrollbar()
Get the scrollbar used for vertical scrolling.- Returns:
- the vertical scrollbar, or null if none specified
-
onBrowserEvent
public void onBrowserEvent(Event event)
Description copied from interface:EventListenerFired whenever a browser event is received.- Specified by:
onBrowserEventin interfaceEventListener- Overrides:
onBrowserEventin classWidget- Parameters:
event- the event received
-
onResize
public void onResize()
Description copied from interface:RequiresResizeThis method must be called whenever the implementor's size has been modified.- Specified by:
onResizein interfaceRequiresResize- Overrides:
onResizein classScrollPanel
-
remove
public boolean remove(Widget w)
Description copied from class:PanelRemoves a child widget.How to Override this Method
There are several important things that must take place in the correct order to properly remove a Widget from a Panel. Not all of these steps will be relevant to every Panel, but all of the steps must be considered.
- Validate: Make sure this Panel is actually the parent of the
child Widget; return
falseif it is not. - Orphan: Call
Panel.orphan(Widget)first while the child Widget is still attached. - Physical Detach: Adjust the DOM to account for the removal of the child Widget. The Widget's Element must be physically removed from the DOM.
- Logical Detach: Update the Panel's state variables to reflect
the removal of the child Widget. Example: the Widget is removed from the
Panel's
WidgetCollection.
- Specified by:
removein interfaceHasWidgets- Overrides:
removein classSimplePanel- Parameters:
w- the widget to be removed- Returns:
trueif the child was present
- Validate: Make sure this Panel is actually the parent of the
child Widget; return
-
removeHorizontalScrollbar
public void removeHorizontalScrollbar()
Remove theHorizontalScrollbar, if one exists.
-
removeVerticalScrollbar
public void removeVerticalScrollbar()
Remove theVerticalScrollbar, if one exists.
-
setAlwaysShowScrollBars
public void setAlwaysShowScrollBars(boolean alwaysShow)
Description copied from class:ScrollPanelSets whether this panel always shows its scroll bars, or only when necessary.- Overrides:
setAlwaysShowScrollBarsin classScrollPanel- Parameters:
alwaysShow-trueto show scroll bars at all times
-
setHorizontalScrollbar
public void setHorizontalScrollbar(HorizontalScrollbar scrollbar, int height)
Set the scrollbar used for horizontal scrolling.- Parameters:
scrollbar- the scrollbar, or null to clear itheight- the height of the scrollbar in pixels
-
setVerticalScrollbar
public void setVerticalScrollbar(VerticalScrollbar scrollbar, int width)
Set the scrollbar used for vertical scrolling.- Parameters:
scrollbar- the scrollbar, or null to clear itwidth- the width of the scrollbar in pixels
-
setWidget
public void setWidget(Widget w)
Description copied from class:SimplePanelSets this panel's widget. Any existing child widget will be removed.- Specified by:
setWidgetin interfaceHasOneWidget- Overrides:
setWidgetin classSimplePanel- Parameters:
w- the panel's new widget, ornullto clear the panel
-
doAttachChildren
protected void doAttachChildren()
Description copied from class:WidgetIf a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and callWidget.onAttach()for each of its child widgets.- Overrides:
doAttachChildrenin classPanel- See Also:
Widget.onAttach()
-
doDetachChildren
protected void doDetachChildren()
Description copied from class:WidgetIf a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and callWidget.onDetach()for each of its child widgets.- Overrides:
doDetachChildrenin classPanel- See Also:
Widget.onDetach()
-
onAttach
protected void onAttach()
Description copied from class:WidgetThis method is called when a widget is attached to the browser's document. To receive notification after a Widget has been added to the document, override the
Widget.onLoad()method or useWidget.addAttachHandler(com.google.gwt.event.logical.shared.AttachEvent.Handler).It is strongly recommended that you override
Widget.onLoad()orWidget.doAttachChildren()instead of this method to avoid inconsistencies between logical and physical attachment states.Subclasses that override this method must call
super.onAttach()to ensure that the Widget has been attached to its underlying Element.- Overrides:
onAttachin classScrollPanel- See Also:
Widget.onLoad(),Widget.doAttachChildren()
-
onDetach
protected void onDetach()
Description copied from class:WidgetThis method is called when a widget is detached from the browser's document. To receive notification before a Widget is removed from the document, override the
Widget.onUnload()method or useWidget.addAttachHandler(com.google.gwt.event.logical.shared.AttachEvent.Handler).It is strongly recommended that you override
Widget.onUnload()orWidget.doDetachChildren()instead of this method to avoid inconsistencies between logical and physical attachment states.Subclasses that override this method must call
super.onDetach()to ensure that the Widget has been detached from the underlying Element. Failure to do so will result in application memory leaks due to circular references between DOM Elements and JavaScript objects.- Overrides:
onDetachin classScrollPanel- See Also:
Widget.onUnload(),Widget.doDetachChildren()
-
-