Class ScrollPanel
- 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
-
- All Implemented Interfaces:
HasScrollHandlers,HasAttachHandlers,HasHandlers,EventListener,AcceptsOneWidget,HasHorizontalScrolling,HasOneWidget,HasScrolling,HasVerticalScrolling,HasVisibility,HasWidgets,HasWidgets.ForIsWidget,IsWidget,ProvidesResize,RequiresResize,SourcesScrollEvents,java.lang.Iterable<Widget>
- Direct Known Subclasses:
CustomScrollPanel
public class ScrollPanel extends SimplePanel implements SourcesScrollEvents, RequiresResize, ProvidesResize, HasScrolling
A simple panel that wraps its contents in a scrollable area.
-
-
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
Constructors Modifier Constructor Description ScrollPanel()Creates an empty scroll panel.protectedScrollPanel(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
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description HandlerRegistrationaddScrollHandler(ScrollHandler handler)Adds aScrollEventhandler.voidaddScrollListener(ScrollListener listener)Deprecated.voidensureVisible(UIObject item)Ensures that the specified item is visible, by adjusting the panel's scroll position.protected ElementgetContainerElement()Override this method to specify that an element other than the root element be the container for the panel's child widget.intgetHorizontalScrollPosition()Gets the horizontal scroll position.intgetMaximumHorizontalScrollPosition()Get the maximum position of horizontal scrolling.intgetMaximumVerticalScrollPosition()Get the maximum position of vertical scrolling.intgetMinimumHorizontalScrollPosition()Get the minimum position of horizontal scrolling.intgetMinimumVerticalScrollPosition()Get the minimum position of vertical scrolling.protected ElementgetScrollableElement()Get the scrollable element.intgetScrollPosition()Deprecated.as of GWT 2.3, replaced bygetVerticalScrollPosition()intgetVerticalScrollPosition()Gets the vertical scroll position.booleanisTouchScrollingDisabled()Check whether or not touch based scrolling is disabled.protected voidonAttach()This method is called when a widget is attached to the browser's document.protected voidonDetach()This method is called when a widget is detached from the browser's document.voidonResize()This method must be called whenever the implementor's size has been modified.voidremoveScrollListener(ScrollListener listener)Deprecated.Use theHandlerRegistration.removeHandler()method on the object returned byaddScrollHandler(com.google.gwt.event.dom.client.ScrollHandler)insteadvoidscrollToBottom()Scroll to the bottom of this panel.voidscrollToLeft()Scroll to the far left of this panel.voidscrollToRight()Scroll to the far right of this panel.voidscrollToTop()Scroll to the top of this panel.voidsetAlwaysShowScrollBars(boolean alwaysShow)Sets whether this panel always shows its scroll bars, or only when necessary.voidsetHeight(java.lang.String height)Sets the object's height.voidsetHorizontalScrollPosition(int position)Sets the horizontal scroll position.voidsetScrollPosition(int position)Deprecated.as of GWT 2.3, replaced bysetVerticalScrollPosition(int)voidsetSize(java.lang.String width, java.lang.String height)Sets the object's size.booleansetTouchScrollingDisabled(boolean isDisabled)Set whether or not touch scrolling is disabled.voidsetVerticalScrollPosition(int position)Sets the vertical scroll position.voidsetWidth(java.lang.String width)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
-
-
-
-
Constructor Detail
-
ScrollPanel
public ScrollPanel()
Creates an empty scroll panel.
-
ScrollPanel
public ScrollPanel(Widget child)
Creates a new scroll panel with the given child widget.- Parameters:
child- the widget to be wrapped by the scroll panel
-
ScrollPanel
protected ScrollPanel(Element root, Element scrollable, Element container)
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 Detail
-
addScrollHandler
public HandlerRegistration addScrollHandler(ScrollHandler handler)
Description copied from interface:HasScrollHandlersAdds aScrollEventhandler.- Specified by:
addScrollHandlerin interfaceHasScrollHandlers- Parameters:
handler- the scroll handler- Returns:
HandlerRegistrationused to remove this handler
-
addScrollListener
@Deprecated public void addScrollListener(ScrollListener listener)
Deprecated.Description copied from interface:SourcesScrollEventsAdds a listener interface to receive scroll events.- Specified by:
addScrollListenerin interfaceSourcesScrollEvents- Parameters:
listener- the listener interface to add
-
ensureVisible
public void ensureVisible(UIObject item)
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:
getHorizontalScrollPositionin interfaceHasHorizontalScrolling- Returns:
- the horizontal scroll position, in pixels
-
getMaximumHorizontalScrollPosition
public int getMaximumHorizontalScrollPosition()
Description copied from interface:HasHorizontalScrollingGet the maximum position of horizontal scrolling. This is usually thescrollWidth - clientWidth.- Specified by:
getMaximumHorizontalScrollPositionin interfaceHasHorizontalScrolling- Returns:
- the maximum horizontal scroll position
-
getMaximumVerticalScrollPosition
public int getMaximumVerticalScrollPosition()
Description copied from interface:HasVerticalScrollingGet the maximum position of vertical scrolling. This is usually thescrollHeight - clientHeight.- Specified by:
getMaximumVerticalScrollPositionin interfaceHasVerticalScrolling- Returns:
- the maximum vertical scroll position
-
getMinimumHorizontalScrollPosition
public int getMinimumHorizontalScrollPosition()
Description copied from interface:HasHorizontalScrollingGet the minimum position of horizontal scrolling.- Specified by:
getMinimumHorizontalScrollPositionin interfaceHasHorizontalScrolling- Returns:
- the minimum horizontal scroll position
-
getMinimumVerticalScrollPosition
public int getMinimumVerticalScrollPosition()
Description copied from interface:HasVerticalScrollingGet the minimum position of vertical scrolling.- Specified by:
getMinimumVerticalScrollPositionin interfaceHasVerticalScrolling- Returns:
- the minimum vertical scroll position
-
getScrollPosition
@Deprecated public int 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:HasVerticalScrollingGets the vertical scroll position.- Specified by:
getVerticalScrollPositionin 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:RequiresResizeThis method must be called whenever the implementor's size has been modified.- Specified by:
onResizein interfaceRequiresResize
-
removeScrollListener
@Deprecated public void removeScrollListener(ScrollListener listener)
Deprecated.Use theHandlerRegistration.removeHandler()method on the object returned byaddScrollHandler(com.google.gwt.event.dom.client.ScrollHandler)insteadDescription copied from interface:SourcesScrollEventsRemoves a previously added scroll listener.- Specified by:
removeScrollListenerin 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-trueto show scroll bars at all times
-
setHeight
public void setHeight(java.lang.String height)
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:
setHorizontalScrollPositionin interfaceHasHorizontalScrolling- Parameters:
position- the new horizontal scroll position, in pixels
-
setScrollPosition
@Deprecated public void setScrollPosition(int position)
Deprecated.as of GWT 2.3, replaced bysetVerticalScrollPosition(int)Sets the vertical scroll position.- Parameters:
position- the new vertical scroll position, in pixels
-
setSize
public void setSize(java.lang.String width, java.lang.String height)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:HasVerticalScrollingSets the vertical scroll position.- Specified by:
setVerticalScrollPositionin interfaceHasVerticalScrolling- Parameters:
position- the new vertical scroll position, in pixels
-
setWidth
public void setWidth(java.lang.String width)
Sets the object's width. This width does not include decorations such as border, margin, and padding.
-
getContainerElement
protected Element getContainerElement()
Description copied from class:SimplePanelOverride 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 theElementclass defined in theUsermodule to maintain backwards compatibility.- Overrides:
getContainerElementin classSimplePanel- Returns:
- the element to be used as the panel's container
-
getScrollableElement
protected Element 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: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 classWidget- 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 classWidget- See Also:
Widget.onUnload(),Widget.doDetachChildren()
-
-