public class

ScrollPanel

extends SimplePanel
implements HasScrollHandlers ProvidesResize RequiresResize SourcesScrollEvents
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

Class Overview

A simple panel that wraps its contents in a scrollable area.

Summary

[Expand]
Inherited Constants
From class com.google.gwt.user.client.ui.UIObject
Public Constructors
ScrollPanel()
Creates an empty scroll panel.
ScrollPanel(Widget child)
Creates a new scroll panel with the given child widget.
Public Methods
HandlerRegistration addScrollHandler(ScrollHandler handler)
Adds a ScrollEvent handler.
void addScrollListener(ScrollListener listener)
This method is deprecated. Use addScrollHandler(ScrollHandler) instead
void ensureVisible(UIObject item)
Ensures that the specified item is visible, by adjusting the panel's scroll position.
int getHorizontalScrollPosition()
Gets the horizontal scroll position.
int getScrollPosition()
Gets the vertical scroll position.
void onResize()
This method must be called whenever the implementor's size has been modified.
void removeScrollListener(ScrollListener listener)
This method is deprecated. Use the removeHandler() method on the object returned by addScrollHandler(ScrollHandler) instead
void scrollToBottom()
Scroll to the bottom of this panel.
void scrollToLeft()
Scroll to the far left of this panel.
void scrollToRight()
Scroll to the far right of this panel.
void scrollToTop()
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 setHeight(String height)
Sets the object's height.
void setHorizontalScrollPosition(int position)
Sets the horizontal scroll position.
void setScrollPosition(int position)
Sets the vertical scroll position.
void setSize(String width, String height)
Sets the object's size.
void setWidth(String width)
Sets the object's width.
Protected Methods
Element getContainerElement()
Override this method to specify that an element other than the root element be the container for the panel's child widget.
[Expand]
Inherited Methods
From class com.google.gwt.user.client.ui.SimplePanel
From class com.google.gwt.user.client.ui.Panel
From class com.google.gwt.user.client.ui.Widget
From class com.google.gwt.user.client.ui.UIObject
From class java.lang.Object
From interface com.google.gwt.event.dom.client.HasScrollHandlers
From interface com.google.gwt.event.logical.shared.HasAttachHandlers
From interface com.google.gwt.event.shared.HasHandlers
From interface com.google.gwt.user.client.EventListener
From interface com.google.gwt.user.client.ui.AcceptsOneWidget
From interface com.google.gwt.user.client.ui.HasOneWidget
From interface com.google.gwt.user.client.ui.HasWidgets
From interface com.google.gwt.user.client.ui.HasWidgets.ForIsWidget
From interface com.google.gwt.user.client.ui.IsWidget
From interface com.google.gwt.user.client.ui.RequiresResize
From interface com.google.gwt.user.client.ui.SourcesScrollEvents
From interface java.lang.Iterable

Public Constructors

public ScrollPanel ()

Creates an empty scroll panel.

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

Public Methods

public HandlerRegistration addScrollHandler (ScrollHandler handler)

Adds a ScrollEvent handler.

Parameters
handler the scroll handler
Returns

public void addScrollListener (ScrollListener listener)

This method is deprecated.
Use addScrollHandler(ScrollHandler) instead

Adds a listener interface to receive scroll events.

Parameters
listener the listener interface to add

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

public int getHorizontalScrollPosition ()

Gets the horizontal scroll position.

Returns
  • the horizontal scroll position, in pixels

public int getScrollPosition ()

Gets the vertical scroll position.

Returns
  • the vertical scroll position, in pixels

public void onResize ()

This method must be called whenever the implementor's size has been modified.

public void removeScrollListener (ScrollListener listener)

This method is deprecated.
Use the removeHandler() method on the object returned by addScrollHandler(ScrollHandler) instead

Removes a previously added scroll listener.

Parameters
listener the listener interface to remove

public void scrollToBottom ()

Scroll to the bottom of this panel.

public void scrollToLeft ()

Scroll to the far left of this panel.

public void scrollToRight ()

Scroll to the far right of this panel.

public void scrollToTop ()

Scroll to the top of this panel.

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

public void setHeight (String height)

Sets the object's height. This height does not include decorations such as border, margin, and padding.

Parameters
height the object's new height, in absolute CSS units (e.g. "10px", "1em" but not "50%")

public void setHorizontalScrollPosition (int position)

Sets the horizontal scroll position.

Parameters
position the new horizontal scroll position, in pixels

public void setScrollPosition (int position)

Sets the vertical scroll position.

Parameters
position the new vertical scroll position, in pixels

public void setSize (String width, String height)

Sets the object's size. This size does not include decorations such as border, margin, and padding.

Parameters
width the object's new width, in absolute CSS units (e.g. "10px", "1em", but not "50%")
height the object's new height, in absolute CSS units (e.g. "10px", "1em", but not "50%")

public void setWidth (String width)

Sets the object's width. This width does not include decorations such as border, margin, and padding.

Parameters
width the object's new width, in absolute CSS units (e.g. "10px", "1em", but not "50%")

Protected Methods

protected Element getContainerElement ()

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 the Element class defined in the User module to maintain backwards compatibility.

Returns
  • the element to be used as the panel's container