Class ScrollPanel
- All Implemented Interfaces:
HasScrollHandlers
,HasAttachHandlers
,HasHandlers
,EventListener
,AcceptsOneWidget
,HasHorizontalScrolling
,HasOneWidget
,HasScrolling
,HasVerticalScrolling
,HasVisibility
,HasWidgets
,HasWidgets.ForIsWidget
,IsWidget
,ProvidesResize
,RequiresResize
,SourcesScrollEvents
,Iterable<Widget>
- Direct Known Subclasses:
CustomScrollPanel
-
Nested Class Summary
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
ModifierConstructorDescriptionCreates an empty scroll panel.protected
ScrollPanel
(Element root, Element scrollable, Element container) Creates an empty scroll panel using the specified root, scrollable, and container elements.ScrollPanel
(Widget child) Creates a new scroll panel with the given child widget. -
Method Summary
Modifier and TypeMethodDescriptionaddScrollHandler
(ScrollHandler handler) Adds aScrollEvent
handler.void
addScrollListener
(ScrollListener listener) Deprecated.void
ensureVisible
(UIObject item) Ensures that the specified item is visible, by adjusting the panel's scroll position.protected Element
Override this method to specify that an element other than the root element be the container for the panel's child widget.int
Gets the horizontal scroll position.int
Get the maximum position of horizontal scrolling.int
Get the maximum position of vertical scrolling.int
Get the minimum position of horizontal scrolling.int
Get the minimum position of vertical scrolling.protected Element
Get the scrollable element.int
Deprecated.as of GWT 2.3, replaced bygetVerticalScrollPosition()
int
Gets the vertical scroll position.boolean
Check whether or not touch based scrolling is disabled.protected void
onAttach()
This method is called when a widget is attached to the browser's document.protected void
onDetach()
This method is called when a widget is detached from the browser's document.void
onResize()
This method must be called whenever the implementor's size has been modified.void
removeScrollListener
(ScrollListener listener) Deprecated.Use theHandlerRegistration.removeHandler()
method on the object returned byaddScrollHandler(com.google.gwt.event.dom.client.ScrollHandler)
insteadvoid
Scroll to the bottom of this panel.void
Scroll to the far left of this panel.void
Scroll to the far right of this panel.void
Scroll to the top of this panel.void
setAlwaysShowScrollBars
(boolean alwaysShow) Sets whether this panel always shows its scroll bars, or only when necessary.void
Sets the object's height.void
setHorizontalScrollPosition
(int position) Sets the horizontal scroll position.void
setScrollPosition
(int position) Deprecated.as of GWT 2.3, replaced bysetVerticalScrollPosition(int)
void
Sets the object's size.boolean
setTouchScrollingDisabled
(boolean isDisabled) Set whether or not touch scrolling is disabled.void
setVerticalScrollPosition
(int position) Sets the vertical scroll position.void
Sets the object's width.Methods inherited from class com.google.gwt.user.client.ui.SimplePanel
add, getWidget, iterator, remove, setWidget, setWidget
Methods inherited from class com.google.gwt.user.client.ui.Panel
add, adopt, clear, doAttachChildren, doDetachChildren, orphan, remove
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, onBrowserEvent, onLoad, 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
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ScrollPanel
public ScrollPanel()Creates an empty scroll panel. -
ScrollPanel
Creates a new scroll panel with the given child widget.- Parameters:
child
- the widget to be wrapped by the scroll panel
-
ScrollPanel
Creates an empty scroll panel using the specified root, scrollable, and container elements.- Parameters:
root
- the root element of the Widgetscrollable
- the scrollable element, which can be the same as the root elementcontainer
- the container element that holds the child
-
-
Method Details
-
addScrollHandler
Description copied from interface:HasScrollHandlers
Adds aScrollEvent
handler.- Specified by:
addScrollHandler
in interfaceHasScrollHandlers
- Parameters:
handler
- the scroll handler- Returns:
HandlerRegistration
used to remove this handler
-
addScrollListener
Deprecated.Description copied from interface:SourcesScrollEvents
Adds a listener interface to receive scroll events.- Specified by:
addScrollListener
in interfaceSourcesScrollEvents
- Parameters:
listener
- the listener interface to add
-
ensureVisible
Ensures that the specified item is visible, by adjusting the panel's scroll position.- Parameters:
item
- the item whose visibility is to be ensured
-
getHorizontalScrollPosition
public int getHorizontalScrollPosition()Gets the horizontal scroll position.- Specified by:
getHorizontalScrollPosition
in interfaceHasHorizontalScrolling
- Returns:
- the horizontal scroll position, in pixels
-
getMaximumHorizontalScrollPosition
public int getMaximumHorizontalScrollPosition()Description copied from interface:HasHorizontalScrolling
Get the maximum position of horizontal scrolling. This is usually thescrollWidth - clientWidth
.- Specified by:
getMaximumHorizontalScrollPosition
in interfaceHasHorizontalScrolling
- Returns:
- the maximum horizontal scroll position
-
getMaximumVerticalScrollPosition
public int getMaximumVerticalScrollPosition()Description copied from interface:HasVerticalScrolling
Get the maximum position of vertical scrolling. This is usually thescrollHeight - clientHeight
.- Specified by:
getMaximumVerticalScrollPosition
in interfaceHasVerticalScrolling
- Returns:
- the maximum vertical scroll position
-
getMinimumHorizontalScrollPosition
public int getMinimumHorizontalScrollPosition()Description copied from interface:HasHorizontalScrolling
Get the minimum position of horizontal scrolling.- Specified by:
getMinimumHorizontalScrollPosition
in interfaceHasHorizontalScrolling
- Returns:
- the minimum horizontal scroll position
-
getMinimumVerticalScrollPosition
public int getMinimumVerticalScrollPosition()Description copied from interface:HasVerticalScrolling
Get the minimum position of vertical scrolling.- Specified by:
getMinimumVerticalScrollPosition
in interfaceHasVerticalScrolling
- Returns:
- the minimum vertical scroll position
-
getScrollPosition
Deprecated.as of GWT 2.3, replaced bygetVerticalScrollPosition()
Gets the vertical scroll position.- Returns:
- the vertical scroll position, in pixels
-
getVerticalScrollPosition
public int getVerticalScrollPosition()Description copied from interface:HasVerticalScrolling
Gets the vertical scroll position.- Specified by:
getVerticalScrollPosition
in interfaceHasVerticalScrolling
- Returns:
- the vertical scroll position, in pixels
-
isTouchScrollingDisabled
public boolean isTouchScrollingDisabled()Check whether or not touch based scrolling is disabled. This method always returns false on devices that do not support touch scrolling.- Returns:
- true if disabled, false if enabled
-
onResize
public void onResize()Description copied from interface:RequiresResize
This method must be called whenever the implementor's size has been modified.- Specified by:
onResize
in interfaceRequiresResize
-
removeScrollListener
Deprecated.Use theHandlerRegistration.removeHandler()
method on the object returned byaddScrollHandler(com.google.gwt.event.dom.client.ScrollHandler)
insteadDescription copied from interface:SourcesScrollEvents
Removes a previously added scroll listener.- Specified by:
removeScrollListener
in interfaceSourcesScrollEvents
- Parameters:
listener
- the listener interface to remove
-
scrollToBottom
public void scrollToBottom()Scroll to the bottom of this panel. -
scrollToLeft
public void scrollToLeft()Scroll to the far left of this panel. -
scrollToRight
public void scrollToRight()Scroll to the far right of this panel. -
scrollToTop
public void scrollToTop()Scroll to the top of this panel. -
setAlwaysShowScrollBars
public void setAlwaysShowScrollBars(boolean alwaysShow) Sets whether this panel always shows its scroll bars, or only when necessary.- Parameters:
alwaysShow
-true
to show scroll bars at all times
-
setHeight
Sets the object's height. This height does not include decorations such as border, margin, and padding. -
setHorizontalScrollPosition
public void setHorizontalScrollPosition(int position) Sets the horizontal scroll position.- Specified by:
setHorizontalScrollPosition
in interfaceHasHorizontalScrolling
- Parameters:
position
- the new horizontal scroll position, in pixels
-
setScrollPosition
Deprecated.as of GWT 2.3, replaced bysetVerticalScrollPosition(int)
Sets the vertical scroll position.- Parameters:
position
- the new vertical scroll position, in pixels
-
setSize
Sets the object's size. This size does not include decorations such as border, margin, and padding. -
setTouchScrollingDisabled
public boolean setTouchScrollingDisabled(boolean isDisabled) Set whether or not touch scrolling is disabled. By default, touch scrolling is enabled on devices that support touch events.- Parameters:
isDisabled
- true to disable, false to enable- Returns:
- true if touch scrolling is enabled and supported, false if disabled or not supported
-
setVerticalScrollPosition
public void setVerticalScrollPosition(int position) Description copied from interface:HasVerticalScrolling
Sets the vertical scroll position.- Specified by:
setVerticalScrollPosition
in interfaceHasVerticalScrolling
- Parameters:
position
- the new vertical scroll position, in pixels
-
setWidth
Sets the object's width. This width does not include decorations such as border, margin, and padding. -
getContainerElement
Description copied from class:SimplePanel
Override this method to specify that an element other than the root element be the container for the panel's child widget. This can be useful when you want to create a simple panel that decorates its contents. Note that this method continues to return theElement
class defined in theUser
module to maintain backwards compatibility.- Overrides:
getContainerElement
in classSimplePanel
- Returns:
- the element to be used as the panel's container
-
getScrollableElement
Get the scrollable element. That is the element with its overflow set to 'auto' or 'scroll'.- Returns:
- the scrollable element
-
onAttach
protected void onAttach()Description copied from class:Widget
This 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. -
onDetach
protected void onDetach()Description copied from class:Widget
This 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.
-
addScrollHandler(com.google.gwt.event.dom.client.ScrollHandler)
instead